QuantumLeap: store the same model with different columns in two tables (timescale)

38 Views Asked by At

I am using NGSI-LD and Orion Context Broker v1.4.

I need to store in two independent tables that start data from the same model but have different attributes.

If I use two subscriptions it stores them in the same table.

1 Subscription:

{
    "description": "Store vehicle data",
    "type": "Subscription",
    "entities": [
        {
            "type": "Vehicle"
        }
    ],
    "watchedAttributes": ["alternateName", "color", "license_plate", "name"],
    "notification": {
    "attributes": ["id", "alternateName", "color", "license_plate", "name"],
        "format": "normalized",
        "endpoint": {
            "uri": "{{qunatumleap}}:8668/v2/notify",
            "accept": "application/json"
        }
    }
}

2 Subscription:

{
    "description": "Store dynamic data",
    "type": "Subscription",
    "entities": [
        {
            "type": "Vehicle"
        }
    ],
    "watchedAttributes": ["location", "heading", "speed"],
    "notification": {
        "attributes": ["id","location", "heading", "speed"],
        "format": "normalized",
        "endpoint": {
            "uri": "{{quantumleap}}:8668/v2/notify",
            "accept": "application/json"
        }
    }
}
1

There are 1 best solutions below

0
Jason Fox On

Effectively what you are asking to do here is to store Timescale data (via QuantumLeap) on to two separate tenants. For QuantumLeap 0.8.3, this was possible for NGSI-LD since QL 0.8.3 relied on the fiware-service header. You could add a receiverInfo key into each subscription to split the data into separate tenants e.g. tenant1, tenant2

"endpoint": {
  "uri": "http://quantumleap:8668/v2/notify",
  "accept": "application/json",
  "receiverInfo": [
    {
      "key": "fiware-service",
      "value": "tenant1"
    }
  ]
}

Now with QuantumLeap 1.0, I think that the NGSILD-Tenant header is now properly supported, so this "trick" won't work directly, but you could relay the information via another microservice. e.g.:

"endpoint": {
  "uri": "http://some-new-micro-service",
  "accept": "application/json",
  "receiverInfo": [
    {
      "key": "fiware-service",
      "value": "tenant1"
    }
  ]
}

All that the new-micro-service would need to do, would be to alter NGSILD-Tenant and combine it with the fiware-service header to come up with a new and unique tenant.

If you combine Orion-LD with Mintaka you could just use the NGSI-LD Temporal interface directly and make separate queries for the two types of data of course - for example using this Grafana plugin