apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboard-temps
  namespace: monitoring
  labels:
    grafana_dashboard: "1"
data:
  hardware-temperatures.json: |
    {
      "annotations": {"list": []},
      "editable": true,
      "graphTooltip": 0,
      "links": [],
      "panels": [
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "fieldConfig": {
            "defaults": {
              "color": {"mode": "thresholds"},
              "unit": "celsius",
              "thresholds": {"mode": "absolute", "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 60},
                {"color": "orange", "value": 75},
                {"color": "red", "value": 85}
              ]}
            },
            "overrides": []
          },
          "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
          "id": 1,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "orientation": "auto",
            "reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false},
            "textMode": "auto"
          },
          "pluginVersion": "11.0.0",
          "title": "Max temperature per host (now)",
          "type": "stat",
          "targets": [
            {"datasource": {"type": "prometheus", "uid": "${datasource}"},
             "expr": "max by (instance) (node_hwmon_temp_celsius)",
             "legendFormat": "{{instance}}", "refId": "A"}
          ]
        },
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "fieldConfig": {
            "defaults": {
              "color": {"mode": "palette-classic"},
              "unit": "celsius",
              "custom": {"drawStyle": "line", "lineWidth": 1, "fillOpacity": 10, "showPoints": "never"},
              "thresholds": {"mode": "absolute", "steps": [
                {"color": "green", "value": null},
                {"color": "red", "value": 85}
              ]}
            },
            "overrides": []
          },
          "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
          "id": 2,
          "options": {
            "legend": {"displayMode": "table", "placement": "bottom", "calcs": ["last", "max"]},
            "tooltip": {"mode": "multi"}
          },
          "title": "All temperature sensors",
          "type": "timeseries",
          "targets": [
            {"datasource": {"type": "prometheus", "uid": "${datasource}"},
             "expr": "node_hwmon_temp_celsius",
             "legendFormat": "{{instance}} / {{chip}} / {{sensor}}", "refId": "A"}
          ]
        }
      ],
      "refresh": "30s",
      "schemaVersion": 39,
      "tags": ["hardware", "temperature"],
      "templating": {"list": [
        {"current": {}, "hide": 0, "includeAll": false, "label": "Datasource",
         "multi": false, "name": "datasource", "options": [], "query": "prometheus",
         "refresh": 1, "type": "datasource"}
      ]},
      "time": {"from": "now-6h", "to": "now"},
      "timezone": "Europe/Oslo",
      "title": "Hardware Temperatures",
      "uid": "hw-temps",
      "version": 1
    }
