Automate datasource & dashboard imports in grafana 83/91583/1
authorSrivahni <srivahni.chivukula@intel.com>
Wed, 17 Jul 2019 07:31:28 +0000 (00:31 -0700)
committerSrivahni <srivahni.chivukula@intel.com>
Wed, 17 Jul 2019 07:39:56 +0000 (00:39 -0700)
Added to grafana-values.yaml

Issue-ID: ONAPARC-393
Signed-off-by: Srivahni <srivahni.chivukula@intel.com>
Change-Id: Id6c8413ea4c4ea69cc7b35f52c2f47b364f5906f

vnfs/DAaaS/deploy/visualization/README.txt [new file with mode: 0755]
vnfs/DAaaS/deploy/visualization/charts/grafana/dashboards/dashboard1.json [new file with mode: 0755]
vnfs/DAaaS/deploy/visualization/charts/grafana/grafana-values.yaml [new file with mode: 0755]
vnfs/DAaaS/deploy/visualization/charts/grafana/templates/configmap-add-dashboard.yaml [new file with mode: 0755]
vnfs/DAaaS/deploy/visualization/charts/grafana/values.yaml

diff --git a/vnfs/DAaaS/deploy/visualization/README.txt b/vnfs/DAaaS/deploy/visualization/README.txt
new file mode 100755 (executable)
index 0000000..a2005d2
--- /dev/null
@@ -0,0 +1,14 @@
+#Add datasource
+Modify "url" in the datasources section of ./charts/grafana/grafana-values.yaml based on the Prometheus or any other service created
+
+#copy the custom dashboards definition into the folder ./charts/grafana/dashboards
+Example, 
+       cp ~/dashboard1.json  ./charts/grafana/dashboards/
+
+#create configmap that imports .json file as config
+configmap found at ./charts/grafana/templates/configmap-add-dashboard.yaml
+
+#Install visualization helm package
+
+helm install -n graf-prometheus . -f ./charts/grafana/values.yaml -f ./charts/grafana/grafana-values.yaml
+
diff --git a/vnfs/DAaaS/deploy/visualization/charts/grafana/dashboards/dashboard1.json b/vnfs/DAaaS/deploy/visualization/charts/grafana/dashboards/dashboard1.json
new file mode 100755 (executable)
index 0000000..3726721
--- /dev/null
@@ -0,0 +1,145 @@
+{
+  "annotations": {
+    "list": [
+      {
+        "builtIn": 1,
+        "datasource": "-- Grafana --",
+        "enable": true,
+        "hide": true,
+        "iconColor": "rgba(0, 211, 255, 1)",
+        "name": "Annotations & Alerts",
+        "type": "dashboard"
+      }
+    ]
+  },
+  "editable": true,
+  "gnetId": null,
+  "graphTooltip": 0,
+  "id": null,
+  "links": [],
+  "panels": [
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 9,
+        "w": 12,
+        "x": 0,
+        "y": 0
+      },
+      "id": 2,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:277",
+          "expr": "collectd_cpu_percent",
+          "format": "time_series",
+          "instant": false,
+          "intervalFactor": 1,
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Panel Title",
+      "tooltip": {
+        "shared": true,
+        "sort": 0,
+        "value_type": "individual"
+      },
+      "type": "graph",
+      "xaxis": {
+        "buckets": null,
+        "mode": "time",
+        "name": null,
+        "show": true,
+        "values": []
+      },
+      "yaxes": [
+        {
+          "format": "short",
+          "label": null,
+          "logBase": 1,
+          "max": null,
+          "min": null,
+          "show": true
+        },
+        {
+          "format": "short",
+          "label": null,
+          "logBase": 1,
+          "max": null,
+          "min": null,
+          "show": true
+        }
+      ],
+      "yaxis": {
+        "align": false,
+        "alignLevel": null
+      }
+    }
+  ],
+  "schemaVersion": 16,
+  "style": "dark",
+  "tags": [],
+  "templating": {
+    "list": []
+  },
+  "time": {
+    "from": "now-6h",
+    "to": "now"
+  },
+  "timepicker": {
+    "refresh_intervals": [
+      "5s",
+      "10s",
+      "30s",
+      "1m",
+      "5m",
+      "15m",
+      "30m",
+      "1h",
+      "2h",
+      "1d"
+    ],
+    "time_options": [
+      "5m",
+      "15m",
+      "1h",
+      "6h",
+      "12h",
+      "24h",
+      "2d",
+      "7d",
+      "30d"
+    ]
+  },
+  "timezone": "",
+  "title": "New dashboard",
+  "uid": null,
+  "version": 0
+}
diff --git a/vnfs/DAaaS/deploy/visualization/charts/grafana/grafana-values.yaml b/vnfs/DAaaS/deploy/visualization/charts/grafana/grafana-values.yaml
new file mode 100755 (executable)
index 0000000..cf04bc8
--- /dev/null
@@ -0,0 +1,39 @@
+grafana:
+#  nodeSelector:
+#    vcmtspktgen: "true"
+
+  datasources:
+    datasources.yaml:
+      apiVersion: 1
+      datasources:
+      - name: Prometheus
+        type: prometheus
+        url: http://cp-prometheus-prometheus.edge1:9090
+        isDefault: true
+        access: proxy
+
+  adminPassword: admin
+
+  image:
+    tag: 5.1.4
+
+  service:
+    type: NodePort
+  #  nodePort: 17765
+
+  # Customer DashBoards configurations
+  dashboardProviders:
+    dashboardproviders.yaml:
+      apiVersion: 1
+      providers:
+      - name: 'dashboard1'
+        orgId: 1
+        folder: ''
+        type: file
+        disableDeletion: false
+        editable: true
+        options:
+          path: /var/lib/grafana/dashboards/dashboard1
+    
+  dashboardsConfigMaps:
+    dashboard1: "custom-dashboard1"
diff --git a/vnfs/DAaaS/deploy/visualization/charts/grafana/templates/configmap-add-dashboard.yaml b/vnfs/DAaaS/deploy/visualization/charts/grafana/templates/configmap-add-dashboard.yaml
new file mode 100755 (executable)
index 0000000..d125f87
--- /dev/null
@@ -0,0 +1,11 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: custom-dashboard1 
+  labels:
+    app: {{ template "grafana.name" . }}
+    chart: {{ template "grafana.chart" . }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+data:
+{{ (.Files.Glob "dashboards/dashboard1.json").AsConfig | indent 2 }}
index 74b511c..582c010 100755 (executable)
@@ -208,18 +208,7 @@ plugins: []
 ## Configure grafana datasources
 ## ref: http://docs.grafana.org/administration/provisioning/#datasources
 ##
-datasources:
-  datasources.yaml:
-    apiVersion: 1
-    datasources:
-    - name: Prometheus
-      type: prometheus
-      url: http://localhost:9090
-      isDefault: true
-    - name: M3DB
-      type: prometheus
-      url: http://m3coordinator-m3db-cluster.edge1.svc.cluster.local:7201
-      access: proxy
+#datasources:
 
 ## Configure notifiers
 ## ref: http://docs.grafana.org/administration/provisioning/#alert-notification-channels