1

I need to send attributes in the northbound direction containing metadata to the CrateDB time series. Sample of the attribute format:

{
    "object_id": "AGV_Error",
    "name": "AGV_Error",
    "type": "Integer",
    "value": 0,
    "metadata": {
        "avg": {
        "value": 25.6,
        "type": "Number"
        },
        "accuracy": {
        "value": 98.7,
        "type": "Number"
        }
    }
}

Although the attribute value is successfully stored in CrateDB, I am still unable to store the metadata. I have tried to check if it is possible to add the metadata inside the subscriptions, but I have not found relevant documentation.

Any suggestions?

Update

Following Filtering out attributes and metadata recommendation, I have included the metadata variable as part of the notifications. E.g.:

    "notification": {
      "http": {"url": "http://quantumleap:'$QUANTUMLEAP_PORT'/v2/notify"},
      "attrs": [
        ....
        "AGV_Error",
        "avg_AGV_Error",
        ...

Then, I attempted to insert the metadata without results. E.g.:

curl -s -o /dev/null -X PUT \
  'http://XXXX:1026/v2/entities/urn:ngsi-ld:Agv:002/attrs/AGV_Error' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /northbound' \
  -d '{
  "value": 86,
  "type": "Number",
  "metadata": {
    "avg_AGV_Error": {
      "value": 25.6,
      "type": "Number"
    },
    "accuracy_AGV_Error": {
      "value": 98.7,
      "type": "Number"
    }
  }
}'

AGV_Error value is successfully updated in CrateDB, but not the metadata. Consider that the information in Mongo DB has not been updated either. This is the orion log:

time=2023-05-18T12:22:47.313Z | lvl=INFO | corr=b2cd8bb6-f576-11ed-9554-0242ac12010b | trans=1684405275-107-00000001503 | from=X.X.X.X | srv=openiot | subsrv=/northbound | comp=Orion | op=logTracing.cpp[148]:logInfoRequestWithPayload | msg=Request received: PUT /v2/entities/urn:ngsi-ld:Agv:002/attrs/AGV_Error, request payload (212 bytes): {
  "value": 86,
  "type": "Number",
  "metadata": {
    "avg_AGV_Error": {
      "value": 125.6,
      "type": "Number"
    },
    "accuracy_AGV_Error": {
      "value": 108.7,
      "type": "Number"
    }
  }
}, response code: 204
sfl0r3nz05
  • 547
  • 8
  • 14

1 Answers1

1

In NGSIv2, attribute metadata are included in notifications by default (except if you use metadata in notification to filter them out).

Thus, I guess that metadata are in the notification sent to CrateDB but due to some reason that I ignore (I'm not an expert in CrateDB) they are not stored as you want.

fgalan
  • 11,732
  • 9
  • 46
  • 89
  • Thank you for your response. I have updated the original request with new tests, but still no results. – sfl0r3nz05 May 18 '23 at 12:29
  • Could you edit your question post to include the notification JSON that Orion sends to CrateDB? Maybe that brings some light to the issue... – fgalan May 23 '23 at 19:26