EDGEPOD-34 Add ability to configure Grafana dashboards to import

Also, bump Prometheus and Grafana helm chart version.

Change-Id: I74ab2f8d70671fa3ccaf2efab2de107c0c5d47b5
diff --git a/nem-monitoring/Chart.yaml b/nem-monitoring/Chart.yaml
index daeb1f6..6fcd7b8 100644
--- a/nem-monitoring/Chart.yaml
+++ b/nem-monitoring/Chart.yaml
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+apiVersion: v1
 name: nem-monitoring
-description: Time Series Storage and Dashboard for SEBA
-version: 1.0.14
+description: Time Series Storage and Dashboard for CORD
+icon: https://guide.opencord.org/logos/cord.svg
+
+version: 1.1.0
diff --git a/nem-monitoring/grafana-dashboards/aaa-stats.json b/nem-monitoring/grafana-dashboards/aaa-stats.json
index 7c8be89..f09c350 100644
--- a/nem-monitoring/grafana-dashboards/aaa-stats.json
+++ b/nem-monitoring/grafana-dashboards/aaa-stats.json
@@ -283,7 +283,9 @@
   ],
   "schemaVersion": 16,
   "style": "dark",
-  "tags": [],
+  "tags": [
+    "seba"
+  ],
   "templating": {
     "list": []
   },
diff --git a/nem-monitoring/grafana-dashboards/kb8s-app-metrics.json b/nem-monitoring/grafana-dashboards/k8s-app-metrics.json
similarity index 99%
rename from nem-monitoring/grafana-dashboards/kb8s-app-metrics.json
rename to nem-monitoring/grafana-dashboards/k8s-app-metrics.json
index 9b5d28f..7cf7796 100644
--- a/nem-monitoring/grafana-dashboards/kb8s-app-metrics.json
+++ b/nem-monitoring/grafana-dashboards/k8s-app-metrics.json
@@ -1319,7 +1319,9 @@
     ],
     "schemaVersion": 14,
     "style": "dark",
-    "tags": [],
+    "tags": [
+      "nem-monitoring"
+    ],
     "templating": {
       "list": [
         {
diff --git a/nem-monitoring/grafana-dashboards/node-exporter.json b/nem-monitoring/grafana-dashboards/node-exporter.json
index 1406430..62e92fa 100644
--- a/nem-monitoring/grafana-dashboards/node-exporter.json
+++ b/nem-monitoring/grafana-dashboards/node-exporter.json
@@ -20836,7 +20836,9 @@
   "refresh": false,
   "schemaVersion": 16,
   "style": "dark",
-  "tags": [],
+  "tags": [
+    "nem-monitoring"
+  ],
   "templating": {
     "list": [
       {
diff --git a/nem-monitoring/grafana-dashboards/omec.json b/nem-monitoring/grafana-dashboards/omec.json
index efb1c90..69b657c 100644
--- a/nem-monitoring/grafana-dashboards/omec.json
+++ b/nem-monitoring/grafana-dashboards/omec.json
@@ -464,7 +464,9 @@
   "refresh": "5s",
   "schemaVersion": 16,
   "style": "dark",
-  "tags": [],
+  "tags": [
+    "comac"
+  ],
   "templating": {
     "list": [
       {
diff --git a/nem-monitoring/grafana-dashboards/onos-kpi.json b/nem-monitoring/grafana-dashboards/onos-kpi.json
index a1e2c0e..c20260a 100644
--- a/nem-monitoring/grafana-dashboards/onos-kpi.json
+++ b/nem-monitoring/grafana-dashboards/onos-kpi.json
@@ -585,7 +585,9 @@
   "refresh": "10s",
   "schemaVersion": 16,
   "style": "dark",
-  "tags": [],
+  "tags": [
+    "nem-monitoring"
+  ],
   "templating": {
     "list": [
       {
diff --git a/nem-monitoring/grafana-dashboards/voltha-kpi.json b/nem-monitoring/grafana-dashboards/voltha-kpi.json
index b76bb2f..9d59d57 100644
--- a/nem-monitoring/grafana-dashboards/voltha-kpi.json
+++ b/nem-monitoring/grafana-dashboards/voltha-kpi.json
@@ -1072,7 +1072,9 @@
   "refresh": "15s",
   "schemaVersion": 16,
   "style": "dark",
-  "tags": [],
+  "tags": [
+    "seba"
+  ],
   "templating": {
     "list": [
       {
diff --git a/nem-monitoring/grafana-dashboards/xos.json b/nem-monitoring/grafana-dashboards/xos.json
index 7e4da5c..69f842f 100644
--- a/nem-monitoring/grafana-dashboards/xos.json
+++ b/nem-monitoring/grafana-dashboards/xos.json
@@ -7844,7 +7844,9 @@
   "refresh": "10s",
   "schemaVersion": 16,
   "style": "dark",
-  "tags": [],
+  "tags": [
+    "nem-monitoring"
+  ],
   "templating": {
     "list": [
       {
diff --git a/nem-monitoring/requirements.yaml b/nem-monitoring/requirements.yaml
index a55e7ea..be9439f 100644
--- a/nem-monitoring/requirements.yaml
+++ b/nem-monitoring/requirements.yaml
@@ -15,9 +15,8 @@
 
 dependencies:
 - name: prometheus
-  version: 6.8.1
+  version: 9.3.1
   repository: https://kubernetes-charts.storage.googleapis.com/
 - name: grafana
-  version: 1.12.0
+  version: 4.0.2
   repository: https://kubernetes-charts.storage.googleapis.com/
-
diff --git a/nem-monitoring/templates/grafana-dashboard-aaa-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-aaa-configmap.yaml
deleted file mode 100644
index 46d51f5..0000000
--- a/nem-monitoring/templates/grafana-dashboard-aaa-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-aaa
-  labels:
-     grafana_dashboard: "1"
-data:
-  aaa.json: |
-{{ .Files.Get "grafana-dashboards/aaa-stats.json" | indent 4 }}
diff --git a/nem-monitoring/templates/grafana-dashboard-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-configmap.yaml
new file mode 100644
index 0000000..c217d20
--- /dev/null
+++ b/nem-monitoring/templates/grafana-dashboard-configmap.yaml
@@ -0,0 +1,50 @@
+---
+# Copyright 2019-present Open Networking Foundation
+#
+# 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: v1
+kind: ConfigMap
+metadata:
+  name: grafana-dashboards
+  labels:
+     grafana_dashboard: "1"
+data:
+{{- if .Values.dashboards.k8s }}
+  k8s.json: |
+{{ .Files.Get "grafana-dashboards/k8s-app-metrics.json" | indent 4 }}
+{{- end }}
+{{- if .Values.dashboards.nodeExporter }}
+  node-exporter.json: |
+{{ .Files.Get "grafana-dashboards/node-exporter.json" | indent 4 }}
+{{- end }}
+{{- if .Values.dashboards.xos }}
+  xos.json: |
+{{ .Files.Get "grafana-dashboards/xos.json" | indent 4 }}
+{{- end }}
+{{- if .Values.dashboards.onos }}
+  onos.json: |
+{{ .Files.Get "grafana-dashboards/onos-kpi.json" | indent 4 }}
+{{- end }}
+{{- if .Values.dashboards.aaa }}
+  aaa.json: |
+{{ .Files.Get "grafana-dashboards/aaa-stats.json" | indent 4 }}
+{{- end }}
+{{- if .Values.dashboards.voltha }}
+  voltha.json: |
+{{ .Files.Get "grafana-dashboards/voltha-kpi.json" | indent 4 }}
+{{- end }}
+{{- if .Values.dashboards.omec }}
+  omec.json: |
+{{ .Files.Get "grafana-dashboards/omec.json" | indent 4 }}
+{{- end }}
diff --git a/nem-monitoring/templates/grafana-dashboard-kb8s-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-kb8s-configmap.yaml
deleted file mode 100644
index 3334c51..0000000
--- a/nem-monitoring/templates/grafana-dashboard-kb8s-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-kb8s
-  labels:
-     grafana_dashboard: "1"
-data:
-  kb8s.json: |
-{{ .Files.Get "grafana-dashboards/kb8s-app-metrics.json" | indent 4 }}
\ No newline at end of file
diff --git a/nem-monitoring/templates/grafana-dashboard-node-exporter.yaml b/nem-monitoring/templates/grafana-dashboard-node-exporter.yaml
deleted file mode 100644
index 684f7e3..0000000
--- a/nem-monitoring/templates/grafana-dashboard-node-exporter.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-node-exporter
-  labels:
-     grafana_dashboard: "1"
-data:
-  xos.json: |
-{{ .Files.Get "grafana-dashboards/node-exporter.json" | indent 4 }}
diff --git a/nem-monitoring/templates/grafana-dashboard-omec-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-omec-configmap.yaml
deleted file mode 100644
index a7b780b..0000000
--- a/nem-monitoring/templates/grafana-dashboard-omec-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-omec
-  labels:
-     grafana_dashboard: "1"
-data:
-  mcord.json: |
-{{ .Files.Get "grafana-dashboards/omec.json" | indent 4 }}
diff --git a/nem-monitoring/templates/grafana-dashboard-onos-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-onos-configmap.yaml
deleted file mode 100644
index 25d270e..0000000
--- a/nem-monitoring/templates/grafana-dashboard-onos-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-onos
-  labels:
-     grafana_dashboard: "1"
-data:
-  onos.json: |
-{{ .Files.Get "grafana-dashboards/onos-kpi.json" | indent 4 }}
\ No newline at end of file
diff --git a/nem-monitoring/templates/grafana-dashboard-voltha-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-voltha-configmap.yaml
deleted file mode 100644
index efbb0dd..0000000
--- a/nem-monitoring/templates/grafana-dashboard-voltha-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-voltha
-  labels:
-     grafana_dashboard: "1"
-data:
-  voltha.json: |
-{{ .Files.Get "grafana-dashboards/voltha-kpi.json" | indent 4 }}
\ No newline at end of file
diff --git a/nem-monitoring/templates/grafana-dashboard-xos-configmap.yaml b/nem-monitoring/templates/grafana-dashboard-xos-configmap.yaml
deleted file mode 100644
index 13b99ef..0000000
--- a/nem-monitoring/templates/grafana-dashboard-xos-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# Copyright 2018-present Open Networking Foundation
-#
-# 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: v1
-kind: ConfigMap
-metadata:
-  name: grafana-dashboard-xos
-  labels:
-     grafana_dashboard: "1"
-data:
-  xos.json: |
-{{ .Files.Get "grafana-dashboards/xos.json" | indent 4 }}
\ No newline at end of file
diff --git a/nem-monitoring/values.yaml b/nem-monitoring/values.yaml
index 47b0682..6d9220e 100644
--- a/nem-monitoring/values.yaml
+++ b/nem-monitoring/values.yaml
@@ -26,7 +26,7 @@
   nem_kpi_exporter_nodePort: 31080
   nem_kpi_exporter_replicas: 2
   kpi_broker: cord-kafka:9092
-  topics: 
+  topics:
     - voltha.kpis
     - onos.aaa.stats.kpis
     - onos.kpis
@@ -35,184 +35,37 @@
   alertmanager:
     persistentVolume:
       enabled: false
-  nodeExporter:
-    service:
-      clusterIP: ""
   server:
     persistentVolume:
       enabled: false
     service:
       type: NodePort
       nodePort: 31301
-  serverFiles:
-    alerts: {}
-    rules: {}
+    # The labels to add to any time series or alerts when communicating with
+    # external systems (federation, remote storage, Alertmanager).
+    #global:
+    #  external_labels:
+    #    datacenter: onf-menlo
 
-    prometheus.yml:
-      rule_files:
-        - /etc/config/rules
-        - /etc/config/alerts
-
-      scrape_configs:
-        # voltha KPI
-        - job_name: 'voltha-kpi'
-          metrics_path: /metrics
-          scrape_interval: 15s
-          static_configs:
-            - targets:
-              - kpi-exporter:8080
-
-        # XOS-Core
-        - job_name: 'xos-core'
-          metrics_path: /metrics
-          scrape_interval: 15s
-          static_configs:
-            - targets:
-              - xos-core-prometheus:8000
-
-        # NodeExporter
-        - job_name: 'node-exporter'
-          metrics_path: /metrics
-          scrape_interval: 15s
-          static_configs:
-            - targets:
-              - nem-monitoring-prometheus-node-exporter:9100
-
-        # KB8s monitoring jobs
-        - job_name: prometheus
-          static_configs:
-            - targets:
-              - localhost:9090
-        - job_name: 'kubernetes-apiservers'
-          kubernetes_sd_configs:
-            - role: endpoints
-          scheme: https
-          tls_config:
-            ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
-            insecure_skip_verify: true
-          bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
-          relabel_configs:
-            - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
-              action: keep
-              regex: default;kubernetes;https
-        - job_name: 'kubernetes-nodes'
-          # Default to scraping over https. If required, just disable this or change to
-          # `http`.
-          scheme: https
-          tls_config:
-            ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
-            insecure_skip_verify: true
-          bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
-          kubernetes_sd_configs:
-            - role: node
-          relabel_configs:
-            - action: labelmap
-              regex: __meta_kubernetes_node_label_(.+)
-            - target_label: __address__
-              replacement: kubernetes.default.svc:443
-            - source_labels: [__meta_kubernetes_node_name]
-              regex: (.+)
-              target_label: __metrics_path__
-              replacement: /api/v1/nodes/${1}/proxy/metrics
-        - job_name: 'kubernetes-nodes-cadvisor'
-          scheme: https
-          tls_config:
-            ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
-            insecure_skip_verify: true
-          bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
-          kubernetes_sd_configs:
-            - role: node
-          relabel_configs:
-            - action: labelmap
-              regex: __meta_kubernetes_node_label_(.+)
-            - target_label: __address__
-              replacement: kubernetes.default.svc:443
-            - source_labels: [__meta_kubernetes_node_name]
-              regex: (.+)
-              target_label: __metrics_path__
-              replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor
-        - job_name: 'kubernetes-service-endpoints'
-          kubernetes_sd_configs:
-            - role: endpoints
-          relabel_configs:
-            - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
-              action: keep
-              regex: true
-            - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
-              action: replace
-              target_label: __scheme__
-              regex: (https?)
-            - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
-              action: replace
-              target_label: __metrics_path__
-              regex: (.+)
-            - source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
-              action: replace
-              target_label: __address__
-              regex: ([^:]+)(?::\d+)?;(\d+)
-              replacement: $1:$2
-            - action: labelmap
-              regex: __meta_kubernetes_service_label_(.+)
-            - source_labels: [__meta_kubernetes_namespace]
-              action: replace
-              target_label: kubernetes_namespace
-            - source_labels: [__meta_kubernetes_service_name]
-              action: replace
-              target_label: kubernetes_name
-        - job_name: 'prometheus-pushgateway'
-          honor_labels: true
-          kubernetes_sd_configs:
-            - role: service
-          relabel_configs:
-            - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_probe]
-              action: keep
-              regex: pushgateway
-        - job_name: 'kubernetes-services'
-          metrics_path: /probe
-          params:
-            module: [http_2xx]
-          kubernetes_sd_configs:
-            - role: service
-          relabel_configs:
-            - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_probe]
-              action: keep
-              regex: true
-            - source_labels: [__address__]
-              target_label: __param_target
-            - target_label: __address__
-              replacement: blackbox
-            - source_labels: [__param_target]
-              target_label: instance
-            - action: labelmap
-              regex: __meta_kubernetes_service_label_(.+)
-            - source_labels: [__meta_kubernetes_namespace]
-              target_label: kubernetes_namespace
-            - source_labels: [__meta_kubernetes_service_name]
-              target_label: kubernetes_name
-        - job_name: 'kubernetes-pods'
-          kubernetes_sd_configs:
-            - role: pod
-          relabel_configs:
-            - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
-              action: keep
-              regex: true
-            - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
-              action: replace
-              target_label: __metrics_path__
-              regex: (.+)
-            - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
-              action: replace
-              regex: ([^:]+)(?::\d+)?;(\d+)
-              replacement: $1:$2
-              target_label: __address__
-            - action: labelmap
-              regex: __meta_kubernetes_pod_label_(.+)
-            - source_labels: [__meta_kubernetes_namespace]
-              action: replace
-              target_label: kubernetes_namespace
-            - source_labels: [__meta_kubernetes_pod_name]
-              action: replace
-              target_label: kubernetes_pod_name
+  extraScrapeConfigs: |
+    - job_name: 'xos-core'
+      metrics_path: /metrics
+      scrape_interval: 15s
+      static_configs:
+        - targets:
+            - xos-core-prometheus:8000
+    - job_name: 'voltha-kpi'
+      metrics_path: /metrics
+      scrape_interval: 15s
+      static_configs:
+        - targets:
+            - kpi-exporter:8080
+    - job_name: 'node-exporter'
+      metrics_path: /metrics
+      scrape_interval: 15s
+      static_configs:
+        - targets:
+          - nem-monitoring-prometheus-node-exporter:9100
 
 grafana:
   adminUser: admin
@@ -230,6 +83,16 @@
       datasources:
         - name: Prometheus
           type: prometheus
-          url: http://nem-monitoring-prometheus-server.default.svc.cluster.local
+          url: http://nem-monitoring-prometheus-server
           access: proxy
           isDefault: true
+
+# Configure Grafana dashboard to import
+dashboards:
+  k8s: true
+  nodeExporter: true
+  xos: true
+  onos: true
+  aaa: true
+  voltha: true
+  omec: false