Dynamic provisioning of grafana resources 80/14380/1
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>
Thu, 8 May 2025 09:44:26 +0000 (15:14 +0530)
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>
Thu, 8 May 2025 09:44:38 +0000 (15:14 +0530)
Create influxdb datasource, flux query and dashboard during grafana startup

Issue-ID: OAM-455
Change-Id: I4077017c40aaa82bc5fd613ca2fd9af0ce763031
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
solution/smo/oam/pm/config/grafana/provisioning/dashboards/dashboards.yaml [new file with mode: 0644]
solution/smo/oam/pm/config/grafana/provisioning/dashboards/o-du_pm-measurements.json [new file with mode: 0644]
solution/smo/oam/pm/config/grafana/provisioning/datasources/datasources.yaml [new file with mode: 0644]
solution/smo/oam/pm/docker-compose-grafana.yaml
solution/smo/oam/pm/setup.sh

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 (file)
index 0000000..3c14afe
--- /dev/null
@@ -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 (file)
index 0000000..5dff5d2
--- /dev/null
@@ -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 (file)
index 0000000..2cb2061
--- /dev/null
@@ -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}
index 1658a74..47f0b1b 100644 (file)
@@ -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
index 9eeb0da..019d36f 100755 (executable)
@@ -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() {