# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2022 Intel Corporation

apiVersion: v1
kind: ConfigMap
metadata:
  name: "{{ .Values.dashboardsConfigMaps.default }}"
  labels:
    name: "{{ .Values.dashboardsConfigMaps.default }}"
  namespace: telemetry
data:
  example-dashboard.json: |
    {
      "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": 2,
      "iteration": 1593421681810,
      "links": [],
      "panels": [
        {
          "datasource": "Prometheus-TLS",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "max": 100,
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "percent"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 0
          },
          "id": 2,
          "options": {
            "displayMode": "lcd",
            "orientation": "horizontal",
            "reduceOptions": {
              "calcs": [
                "mean"
              ],
              "fields": "",
              "values": false
            },
            "showUnfilled": true
          },
          "pluginVersion": "7.0.3",
          "targets": [
            {
              "expr": "100 - (avg(irate(node_cpu_seconds_total{instance=~\"$node\",mode=\"idle\"}[30m])) * 100)",
              "interval": "",
              "intervalFactor": 1,
              "legendFormat": "CPU",
              "refId": "A"
            },
            {
              "expr": "100 - ((node_memory_MemAvailable_bytes{instance=\"$node\"} / node_memory_MemTotal_bytes{instance=\"$node\"}) * 100)",
              "interval": "",
              "legendFormat": "RAM",
              "refId": "B"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "CPU and RAM utilization",
          "type": "bargauge"
        },
        {
          "datasource": "Prometheus-TLS",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "decimals": 0,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 50
                  }
                ]
              },
              "unit": "celsius"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 0
          },
          "id": 4,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "vertical",
            "reduceOptions": {
              "calcs": [
                "mean"
              ],
              "fields": "",
              "values": false
            }
          },
          "pluginVersion": "7.0.3",
          "targets": [
            {
              "expr": "avg(node_hwmon_temp_celsius{instance=\"$node\"})",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Average temperature",
          "transformations": [],
          "type": "stat"
        },
        {
          "datasource": "Prometheus-TLS",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "decimals": 1,
              "mappings": [],
              "max": 1,
              "min": 0,
              "thresholds": {
                "mode": "percentage",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "percentunit"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 8
          },
          "id": 8,
          "options": {
            "displayMode": "gradient",
            "orientation": "horizontal",
            "reduceOptions": {
              "calcs": [
                "mean"
              ],
              "fields": "",
              "values": false
            },
            "showUnfilled": true
          },
          "pluginVersion": "7.0.3",
          "targets": [
            {
              "expr": "(node_filesystem_size_bytes{instance=\"$node\",fstype=\"rootfs\"} - node_filesystem_avail_bytes{instance=\"$node\",fstype=\"rootfs\"})/node_filesystem_size_bytes{instance=\"$node\",fstype=\"rootfs\"}",
              "interval": "",
              "legendFormat": "rootfs",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Used disk space",
          "transformations": [],
          "type": "bargauge"
        },
        {
          "datasource": "Prometheus-TLS",
          "fieldConfig": {
            "defaults": {
              "custom": {
                "align": null
              },
              "decimals": 1,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "bytes"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 9
          },
          "id": 6,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "mean"
              ],
              "fields": "",
              "values": false
            }
          },
          "pluginVersion": "7.0.3",
          "targets": [
            {
              "expr": "node_network_transmit_bytes_total{instance=\"$node\"}",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Total RX/TX",
          "transformations": [
            {
              "id": "reduce",
              "options": {
                "reducers": [
                  "sum"
                ]
              }
            }
          ],
          "type": "stat"
        }
      ],
      "refresh": "5s",
      "schemaVersion": 25,
      "style": "dark",
      "tags": [],
      "templating": {
        "list": [
          {
            "allValue": null,
            "current": {
              "selected": true,
              "text": "node-exporter",
              "value": "node-exporter"
            },
            "datasource": "Prometheus-TLS",
            "definition": "label_values(node_uname_info,  job)",
            "hide": 0,
            "includeAll": false,
            "label": "JOB",
            "multi": false,
            "name": "job",
            "options": [],
            "query": "label_values(node_uname_info,  job)",
            "refresh": 1,
            "regex": "",
            "skipUrlSync": false,
            "sort": 1,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": false
          },
          {
            "allValue": null,
            "datasource": "Prometheus-TLS",
            "definition": "label_values(node_uname_info{job=~\"$job\"}, nodename)",
            "hide": 0,
            "includeAll": true,
            "label": "Host",
            "multi": true,
            "name": "hostname",
            "options": [],
            "query": "label_values(node_uname_info{job=~\"$job\"}, nodename)",
            "refresh": 1,
            "regex": "",
            "skipUrlSync": false,
            "sort": 0,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": false
          },
          {
            "allValue": null,
            "datasource": "Prometheus-TLS",
            "definition": "label_values(node_uname_info{nodename=~\"$hostname\"}, instance)",
            "hide": 0,
            "includeAll": true,
            "label": "IP",
            "multi": false,
            "name": "node",
            "options": [],
            "query": "label_values(node_uname_info{nodename=~\"$hostname\"}, instance)",
            "refresh": 1,
            "regex": "",
            "skipUrlSync": false,
            "sort": 1,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": false
          }
        ]
      },
      "time": {
        "from": "now-15m",
        "to": "now"
      },
      "timepicker": {
        "refresh_intervals": [
          "10s",
          "30s",
          "1m",
          "5m",
          "15m",
          "30m",
          "1h",
          "2h",
          "1d"
        ]
      },
      "timezone": "",
      "title": "Example dashboard",
      "uid": "ZHlJpiMGk",
      "version": 2
    }
