I have followed the official guide about entity creation/update and subscribtion in Orion, they are working and I get success responses. But Orion doesnt send notifications to Cygnus.
Am i missing some step here?
These are the basic scripts I am using:
create entity
{
"contextElements": [{
"type": "Room",
"isPattern": "false",
"id": "2FebRoom",
"attributes": [{
"name": "temperature",
"type": "float",
"value": "888"
}]
}],
"updateAction": "APPEND"
}
subscribe entity http://orion.lab.fiware.org:1026/v1/subscribeContext
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "2FebRoom"
}
],
"attributes": [
"temperature"
],
"reference": "http://A.B.C.D:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"temperature"
]
}
],
"throttling": "PT5S"
}
update entity
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "2FebRoom",
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "111"
}
]
}
],
"updateAction": "UPDATE"
}
I can query the new value in Orion after the update operation but Cygnus doesnt receive any notification, what would be the problem?
Many thanks
Problem was caused by a temporal outage in outgoing notifications from orion.lab.fiware.org. The problem has been solved.
Related
Need to find rank of a company lets say McDonalds in various scenarios in druid. For this purpose I came across an extension called "druid-datasketches" which I think can be helpful.
After going through the documentation I was able to form this query but its incorrect.
{
"queryType": "topN",
"dataSource": "company",
"granularity": "all",
"intervals": [
"2021-01-01T00:00:00/2021-02-28T23:59:59"
],
"dimension": "corporation",
"threshold": 50,
"metric": "rank",
"aggregations": [
{
"type": "doubleSum",
"name": "cr_sales",
"fieldName": "cr_sales"
},
{
"type": "quantilesDoublesSketch",
"name": "skechers",
"fieldName": "cr_sales",
"k": 4096
}
],
"postAggregations": [
{
"type": "quantilesDoublesSketchToRank",
"name": "rank",
"field": {
"type": "fieldAccess",
"fieldName": "skechers"
},
"value": "McDonalds"
}
],
"context": {
"skipEmptyBuckets": true,
"minTopNThreshold": 100000,
"populateResultLevelCache": false
}
}
Need some guidance to be able to form the correct query.
Is there a way to upsert multiple enitites to the Context Broker v2 in a single http-request like submitting an array in the request?
I have something like this in mind:
[POST] /v2/entities/?options=upsert
[
{
id: 'urn:ngsi-ld:xyz:123',
type: 'xyz',
...
},
{
id: 'urn:ngsi-ld:xyz:456',
type: 'xyz',
...
},
...
]
Yes, using POST /v2/update with append action type. For instance (example taken from NGSIv2 API walkthrough):
POST /v2/op/update
{
"actionType": "append",
"entities": [
{
"type": "Room",
"id": "Room3",
"temperature": {
"value": 21.2,
"type": "Float"
},
"pressure": {
"value": 722,
"type": "Integer"
}
},
{
"type": "Room",
"id": "Room4",
"temperature": {
"value": 31.8,
"type": "Float"
},
"pressure": {
"value": 712,
"type": "Integer"
}
}
]
}
That will update Room3 and Room4 entities if they previously exist or create them if they don't previously exist.
I'm emulating a dummy scenario to play around with Perseo and Orion. I'm using 4 docker containers: Mongo, Orion, Perseo FE, and Perseo Core. All of them running healthy.
The steps that I'm doing are:
First, I create the entity with POST to Orion (localhost:1026/v2/entities). This entity looks like this:
{
"id": "DummyEvent1",
"type": "DummyEvent",
"identification": {
"value": "default",
"type": "String"
}
}
Second, I create a subscription with a POST to Orion (localhost:1026/v2/subscriptions) in order to push this DummyEvent from Orion to Perseo:
{
"description": "A subscription to get info about DummyEvent1",
"subject": {
"entities": [
{
"id": "DummyEvent1",
"type": "DummyEvent"
}
],
"condition": {
"attrs": [ ]
}
},
"notification": {
"http": {
"url": "http://perseo-fe:9090/notices"
},
"attrs": [
"identification"
]
}
}
Third, If I GET all the subscriptions in Orion (localhost:1026/v2/subscriptions), I can see that Orion is forwading the DummyEvent correctly to Perseo:
{
"id": "5ca5c18ab07f5ae96aa12152",
"description": "A subscription to get info about DummyEvent1",
"status": "active",
"subject": {
"entities": [
{
"id": "DummyEvent1",
"type": "DummyEvent"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"timesSent": 1,
"lastNotification": "2019-04-04T08:34:18.00Z",
"attrs": [
"identification"
],
"attrsFormat": "normalized",
"http": {
"url": "http://perseo-fe:9090/notices"
},
"lastSuccess": "2019-04-04T08:34:18.00Z",
"lastSuccessCode": 200
}
}
Fourth, But the problem appears when I try to POST a rule in Perseo (localhost:8080/perseo-core/rules) using this DummyEvent:
{
"name": "dummy_rule",
"text": "select * from DummyEvent",
"action": {
"type": "update",
"parameters": {
"name": "identification",
"value": "updatedValue",
"type": "string"
}
}
}
Perseo tells me this:
{
"error": "Failed to resolve event type: Event type or class named 'DummyEvent' was not found [select * from DummyEvent]"
}
What am I doing wrong?
Thanks!
I install the followin docker image of cygnus this. And when i try to make a subscription like the tutorial example i got the following error:
POST /v1/subscriptions&ngsi_version=2 not implemented
This is my POST request:
{
"subscription":{
"description": "One subscription to rule them all",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "Room"
}
],
"condition": {
"attrs": [
"temperature"
],
"expression": {
"q": "temperature>40"
}
}
},
"notification": {
"http": {
"url": "http://localhost:5050"
},
"attrs": [
"temperature",
"humidity"
]
},
"duration": "P1M",
"throttling": 5
},
"endpoint":{
"host":"151.80.41.166",
"port":"50001",
"ssl":"false",
"xauthtoken":"QsENv67AJj7blC2qJ0YvfSc5hMWYrs"
}
}
How i can enable the ngsi_version 2?
I'm using the new release of the contextbroker 0.13.0. In this new version is possible to attach metadata to the attributes of the entities. I can't find any example of how could attach this metadata using JSON. Could you show me an example?
The message could be somthing like it?
{
"contextElements": [
{
"type": "analyzer",
"isPattern": "false",
"id": "metadata",
"attributes": [
{
"name": "ae",
"type": "kWh",
"value": "4",
"Metadata": {["name": "ts",
"type": "ms",
"value": "1401894337000"]}
}
]
}
],
"updateAction": "APPEND"
}
Thank you in advance!
Try with the following updateContext:
{
"contextElements": [
{
"type": "analyzer",
"isPattern": "false",
"id": "metadata",
"attributes": [
{
"name": "ae",
"type": "kWh",
"value": "4",
"metadatas": [
{
"name": "ts",
"type": "ms",
"value": "1401894337000"
}
]
}
]
}
],
"updateAction": "APPEND"
}
The right JSON field for metadata is metadatas (starting with lowercase and ending with 's').
A JSON example has been added in the custom metadata section