From 8aebf1a40c762d89da5245d87b15b259070706fa Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Thu, 8 May 2025 15:14:26 +0530 Subject: [PATCH] Dynamic provisioning of grafana resources Create influxdb datasource, flux query and dashboard during grafana startup Issue-ID: OAM-455 Change-Id: I4077017c40aaa82bc5fd613ca2fd9af0ce763031 Signed-off-by: Ravi Pendurty --- .../provisioning/dashboards/dashboards.yaml | 23 ++++ .../dashboards/o-du_pm-measurements.json | 132 +++++++++++++++++++++ .../provisioning/datasources/datasources.yaml | 29 +++++ solution/smo/oam/pm/docker-compose-grafana.yaml | 8 ++ solution/smo/oam/pm/setup.sh | 2 +- 5 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 solution/smo/oam/pm/config/grafana/provisioning/dashboards/dashboards.yaml create mode 100644 solution/smo/oam/pm/config/grafana/provisioning/dashboards/o-du_pm-measurements.json create mode 100644 solution/smo/oam/pm/config/grafana/provisioning/datasources/datasources.yaml diff --git a/solution/smo/oam/pm/config/grafana/provisioning/dashboards/dashboards.yaml b/solution/smo/oam/pm/config/grafana/provisioning/dashboards/dashboards.yaml new file mode 100644 index 0000000..3c14afe --- /dev/null +++ b/solution/smo/oam/pm/config/grafana/provisioning/dashboards/dashboards.yaml @@ -0,0 +1,23 @@ +# Copyright 2025 highstreet technologies USA Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: 1 + +providers: + - name: 'default' + folder: O-DU PM + type: file + updateIntervalSeconds: 30 + options: + path: /etc/grafana/provisioning/dashboards diff --git a/solution/smo/oam/pm/config/grafana/provisioning/dashboards/o-du_pm-measurements.json b/solution/smo/oam/pm/config/grafana/provisioning/dashboards/o-du_pm-measurements.json new file mode 100644 index 0000000..5dff5d2 --- /dev/null +++ b/solution/smo/oam/pm/config/grafana/provisioning/dashboards/o-du_pm-measurements.json @@ -0,0 +1,132 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Depicts O-DU PM Measurements", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "influxdb", + "uid": "influxdb2-pm-data" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "influxdb", + "uid": "influxdb2-pm-data" + }, + "query": "from(bucket: \"pm-logg-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"ManagedElement=pynts-o-du-o1,ManagedElement=pynts-o-du-o1,GNBDUFunction=pynts-o-du-o1,NRCellDU=1\")\n |> filter(fn: (r) => r[\"_field\"] == \"DRB.MeanActiveUeDl\" or r[\"_field\"] == \"DRB.MeanActiveUeUl\" or r[\"_field\"] == \"DRB.UEThpDl\" or r[\"_field\"] == \"DRB.UEThpUl\" or r[\"_field\"] == \"GranularityPeriod\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")", + "refId": "A" + } + ], + "title": "O-DU PM Measurements", + "type": "timeseries" + } + ], + "refresh": "", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "O-DU PM Measurements", + "uid": "c10ac483-66aa-4c33-8268-6f4d680759bd", + "version": 1, + "weekStart": "" + } \ No newline at end of file diff --git a/solution/smo/oam/pm/config/grafana/provisioning/datasources/datasources.yaml b/solution/smo/oam/pm/config/grafana/provisioning/datasources/datasources.yaml new file mode 100644 index 0000000..2cb2061 --- /dev/null +++ b/solution/smo/oam/pm/config/grafana/provisioning/datasources/datasources.yaml @@ -0,0 +1,29 @@ +# Copyright 2025 highstreet technologies USA Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: 1 + +datasources: + - uid: influxdb2-pm-data + name: InfluxDB + type: influxdb + access: proxy + url: http://influxdb2:8086 + isDefault: true + jsonData: + version: Flux + organization: ${INFLUX_ORG} + defaultBucket: ${INFLUX_BUCKET} + secureJsonData: + token: ${INFLUX_TOKEN} diff --git a/solution/smo/oam/pm/docker-compose-grafana.yaml b/solution/smo/oam/pm/docker-compose-grafana.yaml index 1658a74..47f0b1b 100644 --- a/solution/smo/oam/pm/docker-compose-grafana.yaml +++ b/solution/smo/oam/pm/docker-compose-grafana.yaml @@ -21,6 +21,11 @@ services: GF_AUTH_GENERIC_OAUTH_ALLOW_ASSIGN_GRAFANA_ADMIN: true GF_AUTH_GENERIC_OAUTH_TLS_SKIP_VERIFY_INSECURE: true GF_LOG_LEVEL: debug + INFLUX_ORG: $INFLUXDB2_ORG + INFLUX_BUCKET: $INFLUXDB2_BUCKET + INFLUX_TOKEN: $INFLUXDB2_TOKEN + volumes: + - ./config/grafana/provisioning:/etc/grafana/provisioning labels: traefik.enable: true traefik.http.routers.grafana.entrypoints: websecure @@ -32,7 +37,10 @@ services: solution: "o-ran-sc-smo" networks: - dmz + - smo networks: dmz: external: true + smo: + external: true diff --git a/solution/smo/oam/pm/setup.sh b/solution/smo/oam/pm/setup.sh index 9eeb0da..019d36f 100755 --- a/solution/smo/oam/pm/setup.sh +++ b/solution/smo/oam/pm/setup.sh @@ -78,7 +78,7 @@ setup_influx() { setup_grafana() { envsubst < docker-compose-grafana.yaml > docker-compose-grafana_gen.yaml - docker compose -p grafana -f docker-compose-grafana.yaml up -d + docker compose -p grafana -f docker-compose-grafana_gen.yaml up -d } create_topics() { -- 2.16.6