orchestracities / ngsi-timeseries-api

QuantumLeap: a FIWARE Generic Enabler to support the usage of NGSIv2 (and NGSI-LD experimentally) data in time-series databases
https://quantumleap.rtfd.io/
MIT License
38 stars 49 forks source link

Typing issue with NGSI-LD and QuantumLeap #351

Closed ghost closed 4 years ago

ghost commented 4 years ago

Describe the bug QuantumLeap does not seem to work well with NGSI-LD, the recorded values are all "null". The problem is probably with the unrecognized "Property", "GeoProperty" and "Relationship" types.

To Reproduce

  1. I created an entity of type Device http://localhost:1026/ngsi-ld/v1/entities { "@context": [ "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", "https://raw.githubusercontent.com/GSMADeveloper/NGSI-LD-Entities/master/examples/Device-context.jsonld" ], "id": "urn:ngsi-ld:Device:test001", "type": "Device", "batteryLevel": { "type": "Property", "value": 0.1 } }

  2. I created the associated subscription http://localhost:1026/ngsi-ld/v1/subscriptions { "@context": "https://raw.githubusercontent.com/GSMADeveloper/NGSI-LD-Entities/master/examples/Device-context.jsonld", "type": "Subscription", "entities": [{"type": "Device"}], "watchedAttributes": ["batteryLevel"], "notification": { "attributes": ["batteryLevel"], "endpoint": { "uri": "http://quantumleap:8668/v2/notify", "accept": "application/json" } } }

  3. I triggered the notification http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:test001/attrs { "batteryLevel": { "type": "Property", "value": 0.2 } }

  4. And what I get in QuantumLeap http://localhost:8668/v2/entities/urn:ngsi-ld:Device:test001 { "attributes": [ { "attrName": "batteryLevel", "values": [ null, null, null ] } ], "entityId": "urn:ngsi-ld:Device:test001", "index": [ "2020-08-12T15:24:35.390+00:00", "2020-08-12T15:25:16.177+00:00", "2020-08-12T15:26:25.133+00:00", ] }

The problem is probably that it does not recognize the type Property (neither GeoProperty and Relationship). WARNING:translators.crate:'Property' is not a supported NGSI type. Please use any of the following: Array, Boolean, ISO8601, DateTime, Integer, geo:json, geo:point, Number, Text, StructuredValue, timeindex. Falling back to Text.

Whole log quantumleap_1 | INFO:geocoding.factory:Env variable USE_GEOCODING not set, using default value of: False quantumleap_1 | INFO:reporter.reporter:Env variable LOGLEVEL not set, using default value of: INFO quantumleap_1 | INFO:translators.factory:Env variable QL_DEFAULT_DB not set, using default value of: crate quantumleap_1 | INFO:translators.factory:Backend selected for tenant 'None' is: crate quantumleap_1 | INFO:translators.crate:Env variable CRATE_HOST set to 'cratedb', using this value. quantumleap_1 | INFO:translators.crate:Env variable CRATE_PORT not set, using default value of: 4200 quantumleap_1 | WARNING:translators.crate:'Property' is not a supported NGSI type. Please use any of the following: Array, Boolean, ISO8601, DateTime, Integer, geo:json, geo:point, Number, Text, StructuredValue, timeindex. Falling back to Text. quantumleap_1 | INFO:translators.config:Env variable KEEP_RAW_ENTITY not set, using default value of: False quantumleap_1 | INFO:reporter.reporter:Env variable LOGLEVEL not set, using default value of: INFO quantumleap_1 | INFO:reporter.reporter:Notification successfully processed quantumleap_1 | 172.18.1.4 - - [13/Aug/2020 08:35:13] "POST /v2/notify HTTP/1.1" 200 - quantumleap_1 | INFO:werkzeug:172.18.1.4 - - [13/Aug/2020 08:35:13] "POST /v2/notify HTTP/1.1" 200 -

To verify this I made manual queries to QuantumLeap with a "Property" type and a "Number" type http://quantumleap/v2/notify { "data": [ { "id": "urn:ngsi-ld:Device:test001", "type": "Device", "batteryLevel": { "type": "Property", "value": 0.5 } } ] } ❌ Value stored is null

http://quantumleap/v2/notify { "data": [ { "id": "urn:ngsi-ld:Device:test001", "type": "Device", "batteryLevel": { "type": "Number", "value": 0.6 } } ] } ✔️ Value stored is 0.6

Expected behavior This is what I expected http://localhost:8668/v2/entities/urn:ngsi-ld:Device:test001 { "attributes": [ { "attrName": "batteryLevel", "values": [ 0.1, 0.2, 0.3 ] } ], "entityId": "urn:ngsi-ld:Device:test001", "index": [ "2020-08-12T15:24:35.390+00:00", "2020-08-12T15:25:16.177+00:00", "2020-08-12T15:26:25.133+00:00", ] }

Environment

chicco785 commented 4 years ago

@pierre-josselin ql does not support ngsi-ld at the time being

c0c0n3 commented 4 years ago

@pierre-josselin closing this issue since implementing NGSI-LD is on our roadmap already :-)