[SEBA-293] Onos KPIs

Change-Id: If46d57075392e83c686b3c4a934c91ac40cca187
diff --git a/nem-monitoring/grafana-dashboards/onos-kpi.json b/nem-monitoring/grafana-dashboards/onos-kpi.json
new file mode 100644
index 0000000..a1e2c0e
--- /dev/null
+++ b/nem-monitoring/grafana-dashboards/onos-kpi.json
@@ -0,0 +1,652 @@
+{
+  "annotations": {
+    "list": [
+      {
+        "$$hashKey": "object:204",
+        "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,
+  "iteration": 1541038643440,
+  "links": [],
+  "panels": [
+    {
+      "collapsed": false,
+      "gridPos": {
+        "h": 1,
+        "w": 24,
+        "x": 0,
+        "y": 0
+      },
+      "id": 5,
+      "panels": [],
+      "repeat": "device",
+      "scopedVars": {
+        "device": {
+          "$$hashKey": "object:861",
+          "selected": false,
+          "text": "of:0000000000000001",
+          "value": "of:0000000000000001"
+        }
+      },
+      "title": "Device $device",
+      "type": "row"
+    },
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 0,
+        "y": 1
+      },
+      "id": 6,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "links": [],
+      "minSpan": 6,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "repeatDirection": "h",
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:335",
+          "expr": "onos_rx_bytes_total{device_id=\"$device\"} / 1024 / 1024",
+          "format": "time_series",
+          "intervalFactor": 1,
+          "legendFormat": "{{ device_id }}:{{ port_id }}",
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Received MB",
+      "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
+      }
+    },
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 12,
+        "y": 1
+      },
+      "id": 7,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "links": [],
+      "minSpan": 6,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "repeatDirection": "h",
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:335",
+          "expr": "onos_tx_bytes_total{device_id=\"$device\"} / 1024 / 1024",
+          "format": "time_series",
+          "intervalFactor": 1,
+          "legendFormat": "{{ device_id }}:{{ port_id }}",
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Transmitted MB",
+      "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
+      }
+    },
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 0,
+        "y": 9
+      },
+      "id": 2,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "links": [],
+      "minSpan": 6,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "repeat": null,
+      "repeatDirection": "h",
+      "scopedVars": {
+        "device": {
+          "$$hashKey": "object:861",
+          "selected": false,
+          "text": "of:0000000000000001",
+          "value": "of:0000000000000001"
+        }
+      },
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:335",
+          "expr": "onos_rx_packets_total{device_id=\"$device\"}",
+          "format": "time_series",
+          "intervalFactor": 1,
+          "legendFormat": "{{ device_id }}:{{ port_id }}",
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Received Packets",
+      "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
+      }
+    },
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 12,
+        "y": 9
+      },
+      "id": 3,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "links": [],
+      "minSpan": 6,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "repeat": null,
+      "repeatDirection": "h",
+      "scopedVars": {
+        "device": {
+          "$$hashKey": "object:861",
+          "selected": false,
+          "text": "of:0000000000000001",
+          "value": "of:0000000000000001"
+        }
+      },
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:335",
+          "expr": "onos_tx_packets_total{device_id=\"$device\"}",
+          "format": "time_series",
+          "intervalFactor": 1,
+          "legendFormat": "{{ device_id }}:{{ port_id }}",
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Transmitted Packets",
+      "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
+      }
+    },
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 0,
+        "y": 17
+      },
+      "id": 8,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "links": [],
+      "minSpan": 6,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "repeatDirection": "h",
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:335",
+          "expr": "onos_rx_drop_packets_total{device_id=\"$device\"}",
+          "format": "time_series",
+          "intervalFactor": 1,
+          "legendFormat": "{{ device_id }}:{{ port_id }}",
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Received Packets Dropped",
+      "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
+      }
+    },
+    {
+      "aliasColors": {},
+      "bars": false,
+      "dashLength": 10,
+      "dashes": false,
+      "datasource": "Prometheus",
+      "fill": 1,
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 12,
+        "y": 17
+      },
+      "id": 9,
+      "legend": {
+        "avg": false,
+        "current": false,
+        "max": false,
+        "min": false,
+        "show": true,
+        "total": false,
+        "values": false
+      },
+      "lines": true,
+      "linewidth": 1,
+      "links": [],
+      "minSpan": 6,
+      "nullPointMode": "null",
+      "percentage": false,
+      "pointradius": 5,
+      "points": false,
+      "renderer": "flot",
+      "repeatDirection": "h",
+      "seriesOverrides": [],
+      "spaceLength": 10,
+      "stack": false,
+      "steppedLine": false,
+      "targets": [
+        {
+          "$$hashKey": "object:335",
+          "expr": "onos_tx_drop_packets_total{device_id=\"$device\"}",
+          "format": "time_series",
+          "intervalFactor": 1,
+          "legendFormat": "{{ device_id }}:{{ port_id }}",
+          "refId": "A"
+        }
+      ],
+      "thresholds": [],
+      "timeFrom": null,
+      "timeShift": null,
+      "title": "Transmitted Packets Dropped",
+      "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
+      }
+    }
+  ],
+  "refresh": "10s",
+  "schemaVersion": 16,
+  "style": "dark",
+  "tags": [],
+  "templating": {
+    "list": [
+      {
+        "allValue": null,
+        "current": {
+          "tags": [],
+          "text": "All",
+          "value": [
+            "$__all"
+          ]
+        },
+        "datasource": "Prometheus",
+        "hide": 0,
+        "includeAll": true,
+        "label": null,
+        "multi": true,
+        "name": "device",
+        "options": [],
+        "query": "label_values(onos_rx_packets_total, device_id)",
+        "refresh": 1,
+        "regex": "",
+        "sort": 0,
+        "tagValuesQuery": "",
+        "tags": [],
+        "tagsQuery": "",
+        "type": "query",
+        "useTags": false
+      }
+    ]
+  },
+  "time": {
+    "from": "now-5m",
+    "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": "ONOS KPIs",
+  "uid": "kqqYHvaiz",
+  "version": 1
+}
\ No newline at end of file
diff --git a/nem-monitoring/grafana-dashboards/voltha-kpi.json b/nem-monitoring/grafana-dashboards/voltha-kpi.json
index bbdbff0..a02fdf9 100644
--- a/nem-monitoring/grafana-dashboards/voltha-kpi.json
+++ b/nem-monitoring/grafana-dashboards/voltha-kpi.json
@@ -17,8 +17,7 @@
   "editable": true,
   "gnetId": null,
   "graphTooltip": 0,
-  "id": 1,
-  "iteration": 1540483073721,
+  "iteration": 1541029831924,
   "links": [],
   "panels": [
     {
@@ -1095,10 +1094,8 @@
       {
         "allValue": null,
         "current": {
-          "$$hashKey": "object:1294",
-          "selected": false,
-          "text": "000000000a5a0072",
-          "value": "000000000a5a0072"
+          "text": "All",
+          "value": "$__all"
         },
         "datasource": "Prometheus",
         "hide": 0,
@@ -1106,28 +1103,9 @@
         "label": "OLT Device",
         "multi": false,
         "name": "olt",
-        "options": [
-          {
-            "$$hashKey": "object:1292",
-            "selected": false,
-            "text": "All",
-            "value": "$__all"
-          },
-          {
-            "$$hashKey": "object:1293",
-            "selected": false,
-            "text": "000000000a5a0073",
-            "value": "000000000a5a0073"
-          },
-          {
-            "$$hashKey": "object:1294",
-            "selected": true,
-            "text": "000000000a5a0072",
-            "value": "000000000a5a0072"
-          }
-        ],
-        "query": "label_values(tx_bytes_total, logical_device_id)",
-        "refresh": 0,
+        "options": [],
+        "query": "label_values(voltha_tx_bytes_total, logical_device_id)",
+        "refresh": 1,
         "regex": "",
         "sort": 0,
         "tagValuesQuery": "",
@@ -1139,7 +1117,6 @@
       {
         "allValue": null,
         "current": {
-          "tags": [],
           "text": "All",
           "value": "$__all"
         },
@@ -1151,19 +1128,17 @@
         "name": "onu",
         "options": [
           {
-            "$$hashKey": "object:389",
             "selected": true,
             "text": "All",
             "value": "$__all"
           },
           {
-            "$$hashKey": "object:390",
             "selected": false,
             "text": "ISKT71e801a0",
             "value": "ISKT71e801a0"
           }
         ],
-        "query": "label_values(tx_packets_total{title=\"Ethernet_Bridge_Port_History\"}, serial_number)",
+        "query": "label_values(voltha_tx_packets_total{title=\"Ethernet_Bridge_Port_History\"}, serial_number)",
         "refresh": 0,
         "regex": "",
         "sort": 0,
@@ -1208,4 +1183,4 @@
   "title": "Voltha",
   "uid": "i9V9JtOmz",
   "version": 1
-}
+}
\ No newline at end of file
diff --git a/nem-monitoring/templates/voltha-exporter-deployment.yaml b/nem-monitoring/templates/exporter-deployment.yaml
similarity index 82%
rename from nem-monitoring/templates/voltha-exporter-deployment.yaml
rename to nem-monitoring/templates/exporter-deployment.yaml
index f69f163..5147c64 100644
--- a/nem-monitoring/templates/voltha-exporter-deployment.yaml
+++ b/nem-monitoring/templates/exporter-deployment.yaml
@@ -16,22 +16,22 @@
 apiVersion: extensions/v1beta1
 kind: Deployment
 metadata:
-  name: voltha-kpi-exporter
+  name: kpi-exporter
   labels:
     release: {{ .Release.Name }}
 spec:
-  replicas: 2
+  replicas: {{ .Values.nem_voltha_kpi_exporter_replicas }}
   template:
     metadata:
       labels:
-        app: voltha-kpi-exporter
+        app: kpi-exporter
         release: {{ .Release.Name }}
     spec:
       containers:
-        - name: voltha-kpi-exporter
+        - name: kpi-exporter
           image: {{ tpl .Values.nem_voltha_kpi_exporter_image . | quote }}
           imagePullPolicy: {{ .Values.imagePullPolicy }}
-          args: ["-broker={{ .Values.args.voltha_kpi_broker }}", "-topic={{ .Values.args.voltha_kpi_topic }}"]
+          args: ["-broker={{ .Values.args.voltha_kpi_broker }}"]
           ports:
             - containerPort: 8080
               port: 8080
diff --git a/nem-monitoring/templates/voltha-exporter-service.yaml b/nem-monitoring/templates/exporter-service.yaml
similarity index 93%
rename from nem-monitoring/templates/voltha-exporter-service.yaml
rename to nem-monitoring/templates/exporter-service.yaml
index 60a67f4..f5fcee2 100644
--- a/nem-monitoring/templates/voltha-exporter-service.yaml
+++ b/nem-monitoring/templates/exporter-service.yaml
@@ -16,7 +16,7 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: voltha-kpi-exporter
+  name: kpi-exporter
   labels:
     release: {{ .Release.Name }}
 spec:
@@ -27,4 +27,4 @@
       nodePort: {{ .Values.nem_voltha_kpi_exporter_nodePort }}
       protocol: TCP
   selector:
-    app: "voltha-kpi-exporter"
+    app: "kpi-exporter"
diff --git a/nem-monitoring/templates/voltha-exporter-service.yaml b/nem-monitoring/templates/grafana-dashboard-onos-configmap.yaml
similarity index 64%
copy from nem-monitoring/templates/voltha-exporter-service.yaml
copy to nem-monitoring/templates/grafana-dashboard-onos-configmap.yaml
index 60a67f4..25d270e 100644
--- a/nem-monitoring/templates/voltha-exporter-service.yaml
+++ b/nem-monitoring/templates/grafana-dashboard-onos-configmap.yaml
@@ -1,5 +1,5 @@
 ---
-# Copyright 2017-present Open Networking Foundation
+# 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.
@@ -14,17 +14,11 @@
 # limitations under the License.
 
 apiVersion: v1
-kind: Service
+kind: ConfigMap
 metadata:
-  name: voltha-kpi-exporter
+  name: grafana-dashboard-onos
   labels:
-    release: {{ .Release.Name }}
-spec:
-  type: NodePort
-  ports:
-    - port: 8080
-      targetPort: 8080
-      nodePort: {{ .Values.nem_voltha_kpi_exporter_nodePort }}
-      protocol: TCP
-  selector:
-    app: "voltha-kpi-exporter"
+     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/values.yaml b/nem-monitoring/values.yaml
index 5c289bc..886e502 100644
--- a/nem-monitoring/values.yaml
+++ b/nem-monitoring/values.yaml
@@ -15,10 +15,10 @@
 
 nem_voltha_kpi_exporter_image: "opencord/kafka-topic-exporter:latest"
 nem_voltha_kpi_exporter_nodePort: 31080
+nem_voltha_kpi_exporter_replicas: 2
 imagePullPolicy: "Always"
 args:
   voltha_kpi_broker: cord-kafka:9092
-  voltha_kpi_topic: voltha.kpis
 
 prometheus:
   alertmanager:
@@ -46,7 +46,7 @@
           scrape_interval: 15s
           static_configs:
             - targets:
-              - voltha-kpi-exporter:8080
+              - kpi-exporter:8080
 
         # XOS-Core
         - job_name: 'xos-core'