Reputation: 15
I deploy a basic FIWARE Scorpio stack with a docker compose :
services:
postgres:
image: postgis/postgis
ports:
- "5432"
environment:
POSTGRES_USER: ngb
POSTGRES_PASSWORD: ngb
POSTGRES_DB: ngb
scorpio:
image: scorpiobroker/all-in-one-runner:java-latest
environment:
DBHOST: postgres
ports:
- "9090:9090"
depends_on:
- postgres
I also have a .sh code to add entities, a part of it is :
SCORPIO_URL="http://localhost:9090/ngsi-ld/v1/temporal/entities"
NGSI_LD_CONTEXT="https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld"
FIWARE_SERVICE="test_service"
FIWARE_SERVICEPATH="/weather"
create_weather_entity() {
response=$(curl -X POST "$SCORPIO_URL" \
-H "Content-Type: application/ld+json" \
-H "fiware-service: $FIWARE_SERVICE" \
-H "fiware-servicepath: $FIWARE_SERVICEPATH" \
-d '{
"id": "urn:ngsi-ld:WeatherObserved:001",
"type": "WeatherObserved",
"temperature": {
"value": 23,
"unitCode": "CEL",
"type": "Property",
"observedAt": "2024-10-10T12:00:00Z"
},
"barometricPressure": {
"value": 720,
"unitCode": "hPa",
"type": "Property",
"observedAt": "2024-10-10T12:00:00Z"
},
"dateObserved": {
"value": "2024-10-10T12:00:00Z",
"type": "Property"
},
"source": {
"value": "http://www.aemet.es",
"type": "Property"
},
"@context": [
{
"WeatherObserved": "urn:mytypes:WeatherObserved",
"temperature": "myuniqueuri:temperature",
"barometricPressure": "myuniqueuri:barometricPressure",
"dateObserved": "myuniqueuri:dateObserved",
"source": "myuniqueuri:source"
},
"'$NGSI_LD_CONTEXT'"
]
}')
echo "Create WeatherObserved Response: $response"
}
And a code to simulate the sending of measurements :
SCORPIO_URL="http://localhost:9090/ngsi-ld/v1/temporal/entities/"
NGSI_LD_CONTEXT="https://fiware.github.io/data-models/context.jsonld"
FIWARE_SERVICE="test_service"
FIWARE_SERVICEPATH="/weather"
send_weather_measurements() {
local temperature=$(shuf -i 15-35 -n 1)
local pressure=$(shuf -i 700-750 -n 1)
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
echo "Sending WeatherObserved measurement:"
echo " Temperature: ${temperature} °C"
echo " Barometric Pressure: ${pressure} hPa"
echo " Observed At: ${timestamp}"
curl -X PATCH "${SCORPIO_URL}urn:ngsi-ld:WeatherObserved:001/attrs" \
-H "Content-Type: application/ld+json" \
-H "fiware-service: $FIWARE_SERVICE" \
-H "fiware-servicepath: $FIWARE_SERVICEPATH" \
-d '{
"temperature": {
"type": "Property",
"value": '"$temperature"',
"observedAt": "'"$timestamp"'"
},
"barometricPressure": {
"type": "Property",
"value": '"$pressure"',
"observedAt": "'"$timestamp"'"
},
"dateObserved": {
"type": "Property",
"value": "'"$timestamp"'"
},
"@context": "'$NGSI_LD_CONTEXT'"
}'
}
I would like to store these historical contexts into the postgres sql db (not ok), and then connect it to Grafana (this part should be ok).
When I do :
curl -X GET "http://localhost:9090/ngsi-ld/v1/temporal/entities/urn:ngsi-ld:WeatherObserved:001"
-H "Content-Type: application/ld+json"
-H "fiware-service: test_service"
-H "fiware-servicepath: /weather"
It works so the entity is saved. But when I check inside the postgres db, I only see these tables and can't find the ones corresponding to my entities :
tiger | faces | table | ngb
tiger | featnames | table | ngb
tiger | geocode_settings | table | ngb
tiger | geocode_settings_default | table | ngb
tiger | loader_lookuptables | table | ngb
tiger | loader_platform | table | ngb
tiger | loader_variables | table | ngb
tiger | pagc_gaz | table | ngb
tiger | pagc_lex | table | ngb
tiger | pagc_rules | table | ngb
tiger | place | table | ngb
tiger | place_lookup | table | ngb
tiger | secondary_unit_lookup | table | ngb
tiger | state | table | ngb
tiger | state_lookup | table | ngb
tiger | street_type_lookup | table | ngb
tiger | tabblock | table | ngb
tiger | tabblock20 | table | ngb
tiger | tract | table | ngb
tiger | zcta5 | table | ngb
tiger | zip_lookup | table | ngb
tiger | zip_lookup_all | table | ngb
tiger | zip_lookup_base | table | ngb
tiger | zip_state | table | ngb
tiger | zip_state_loc | table | ngb
topology | layer | table | ngb
topology | topology | table | ngb
How should I do to store the historical values into a postgres SQL database?
Thank you in advance for any help!
Upvotes: 0
Views: 75