From 185ba6099744a191d19768fed8fd11df0a1546db Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 5 May 2026 16:01:42 +0200 Subject: [PATCH] Added NGSI-LD Grafana datasource plugin and Scorpio --- README.md | 72 +++++++++++++++++++++++++++++++++- Taskfile.yml | 20 ++++++++++ docker-compose.quantumleap.yml | 43 +++++++++++++++++++- grafana/plugins/.gitignore | 4 ++ grafana/plugins/Taskfile.yml | 14 +++++++ scripts/scorpio-generate-data | 28 +++++++++++++ scripts/scorpio-one-ping-only | 14 +++++++ 7 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 grafana/plugins/.gitignore create mode 100644 grafana/plugins/Taskfile.yml create mode 100755 scripts/scorpio-generate-data create mode 100755 scripts/scorpio-one-ping-only diff --git a/README.md b/README.md index e14c0ae..9cf2bde 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Based on . Start the show: ``` shell name=start -task compose -- pull -task compose -- up --detach --wait +task install +task start open https://orion.quantumleap.local.itkdev.dk open https://grafana.quantumleap.local.itkdev.dk @@ -75,6 +75,57 @@ task compose -- exec --no-TTY orion curl --silent --show-error localhost:1026/v2 EOF ``` +``` shell name=scorpio-entity-create +# https://fiware-scorpio.readthedocs.io/en/master/user/walkthrough_apiv2.html#entity-creation +task compose -- exec --no-TTY scorpio curl --silent --show-error localhost:9090/ngsi-ld/v1/entities --header 'content-type: application/json' --data @- < [!IMPORTANT] +> The value of "Temporal broker URL" _must_ be the value of "Context broker URL" followed by `/ngsi-ld/v1`. diff --git a/Taskfile.yml b/Taskfile.yml index 1086be1..ee579c8 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -11,7 +11,27 @@ dotenv: vars: DOCKER_COMPOSE: '{{.TASK_DOCKER_COMPOSE | default "docker compose"}}' +includes: + grafana:plugins: + taskfile: ./grafana/plugins/Taskfile.yml + dir: ./grafana/plugins + tasks: + install: + desc: Install plugins + cmds: + - task: grafana:plugins:update + + start: + desc: Start the show + cmds: + - task: compose + vars: + TASK_ARGS: pull + - task: compose + vars: + TASK_ARGS: up --detach --remove-orphans --wait + grafana:reset-database: desc: Reset Grafana database prompt: Really? diff --git a/docker-compose.quantumleap.yml b/docker-compose.quantumleap.yml index 92329be..66d8761 100644 --- a/docker-compose.quantumleap.yml +++ b/docker-compose.quantumleap.yml @@ -4,6 +4,7 @@ networks: quantumleap: + scorpio: services: orion: @@ -115,11 +116,51 @@ services: # - GF_SERVER_HTTP_PORT=80 # https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#data - GF_PATHS_DATA=/var/lib/grafana # The default value + + - GF_PATHS_PLUGINS=/var/lib/grafana/plugins # The default value + # https://github.com/bfi-de/ngsild-grafana-datasource/blob/main/README.md + - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=ngsild-grafana-datasource volumes: # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ #- ./grafana/grafana.ini://etc/grafana/grafana.ini # https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/ - ./grafana/provisioning:/etc/grafana/provisioning - - ./grafana/provisioning:/etc/grafana/provisioning # Cf. environment variable GF_PATHS_DATA - ./.docker/data/grafana/grafana.db:/var/lib/grafana/grafana.db + + # https://github.com/bfi-de/ngsild-grafana-datasource/blob/main/README.md + - ./grafana/plugins/ngsild-grafana-datasource:/var/lib/grafana/plugins/ngsild-grafana-datasource:ro + + scorpio: + image: scorpiobroker/all-in-one-runner:java-latest + environment: + DBHOST: scorpio-db + # ports: + # - "9090" + depends_on: + - scorpio-db + networks: + - frontend + - quantumleap + - scorpio + labels: + - "traefik.enable=true" + - "traefik.docker.network=frontend" + - "traefik.http.routers.${COMPOSE_PROJECT_NAME:?}_scorpio.rule=Host(`scorpio.${COMPOSE_DOMAIN:?}`)" + - "traefik.http.services.${COMPOSE_PROJECT_NAME:?}_scorpio.loadbalancer.server.port=9090" + # HTTPS config + - "traefik.http.routers.${COMPOSE_PROJECT_NAME:?}.middlewares=redirect-to-https" + - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + + scorpio-db: + image: postgis/postgis + ports: + - "5432" + environment: + POSTGRES_USER: ngb + POSTGRES_PASSWORD: ngb + POSTGRES_DB: ngb + networks: + - scorpio + volumes: + - .docker/data/scorpio-db:/var/lib/postgresql/data diff --git a/grafana/plugins/.gitignore b/grafana/plugins/.gitignore new file mode 100644 index 0000000..e4ce1c7 --- /dev/null +++ b/grafana/plugins/.gitignore @@ -0,0 +1,4 @@ +# Ignore almost anything +* +!.gitignore +!Taskfile.yml diff --git a/grafana/plugins/Taskfile.yml b/grafana/plugins/Taskfile.yml new file mode 100644 index 0000000..86a4e5b --- /dev/null +++ b/grafana/plugins/Taskfile.yml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=https://taskfile.dev/schema.json + +version: '3' + +vars: + NGSILD_GRAFANA_DATASOURCE_VERSION: 1.2.2 + +tasks: + update: + desc: Update all plugins + cmds: + # https://github.com/bfi-de/ngsild-grafana-datasource/blob/main/README.md + - curl --location --silent https://github.com/bfi-de/ngsild-grafana-datasource/releases/download/v{{.NGSILD_GRAFANA_DATASOURCE_VERSION}}/ngsild-grafana-datasource-{{.NGSILD_GRAFANA_DATASOURCE_VERSION}}.tgz --output ngsild-grafana-datasource.tgz + - tar xf ngsild-grafana-datasource.tgz diff --git a/scripts/scorpio-generate-data b/scripts/scorpio-generate-data new file mode 100755 index 0000000..c5e6c47 --- /dev/null +++ b/scripts/scorpio-generate-data @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) + +echo "Creating entity" +# https://fiware-scorpio.readthedocs.io/en/master/user/walkthrough_apiv2.html#entity-creation +task compose -- exec --no-TTY scorpio curl --silent --show-error localhost:9090/ngsi-ld/v1/entities --header 'content-type: application/json' --data @- <