# ============================================================================
# Grafana Dashboards as ConfigMaps
# ============================================================================

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: undateable-overview-dashboard
  namespace: monitoring
  labels:
    grafana_dashboard: "1"
data:
  undateable-overview.json: |
    {
      "annotations": {
        "list": []
      },
      "editable": true,
      "fiscalYearStartMonth": 0,
      "graphTooltip": 0,
      "id": null,
      "links": [],
      "liveNow": false,
      "panels": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  { "color": "green", "value": null },
                  { "color": "red", "value": 0 }
                ]
              }
            }
          },
          "gridPos": { "h": 4, "w": 4, "x": 0, "y": 0 },
          "id": 1,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": ["lastNotNull"],
              "fields": "",
              "values": false
            },
            "textMode": "auto"
          },
          "pluginVersion": "9.0.0",
          "targets": [
            {
              "expr": "sum(up{namespace=\"undateable\"})",
              "refId": "A"
            }
          ],
          "title": "Services Up",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "unit": "reqps"
            }
          },
          "gridPos": { "h": 4, "w": 4, "x": 4, "y": 0 },
          "id": 2,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": ["lastNotNull"],
              "fields": "",
              "values": false
            }
          },
          "targets": [
            {
              "expr": "sum(rate(nginx_ingress_controller_requests{namespace=\"undateable\"}[5m]))",
              "refId": "A"
            }
          ],
          "title": "Requests/sec",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "unit": "percent"
            }
          },
          "gridPos": { "h": 4, "w": 4, "x": 8, "y": 0 },
          "id": 3,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": ["lastNotNull"],
              "fields": "",
              "values": false
            }
          },
          "targets": [
            {
              "expr": "100 - (sum(rate(nginx_ingress_controller_requests{status=~\"5..\"}[5m])) / sum(rate(nginx_ingress_controller_requests[5m])) * 100)",
              "refId": "A"
            }
          ],
          "title": "Success Rate",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "unit": "s"
            }
          },
          "gridPos": { "h": 4, "w": 4, "x": 12, "y": 0 },
          "id": 4,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": ["lastNotNull"],
              "fields": "",
              "values": false
            }
          },
          "targets": [
            {
              "expr": "histogram_quantile(0.95, sum(rate(nginx_ingress_controller_request_duration_seconds_bucket[5m])) by (le))",
              "refId": "A"
            }
          ],
          "title": "P95 Latency",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "custom": {
                "axisCenteredZero": false,
                "axisColorMode": "text",
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 10,
                "gradientMode": "none",
                "hideFrom": { "legend": false, "tooltip": false, "viz": false },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": { "type": "linear" },
                "showPoints": "never",
                "spanNulls": false,
                "stacking": { "group": "A", "mode": "none" },
                "thresholdsStyle": { "mode": "off" }
              },
              "unit": "reqps"
            }
          },
          "gridPos": { "h": 8, "w": 12, "x": 0, "y": 4 },
          "id": 5,
          "options": {
            "legend": { "calcs": [], "displayMode": "list", "placement": "bottom" },
            "tooltip": { "mode": "single", "sort": "none" }
          },
          "targets": [
            {
              "expr": "sum(rate(nginx_ingress_controller_requests{namespace=\"undateable\"}[5m])) by (service)",
              "legendFormat": "{{ service }}",
              "refId": "A"
            }
          ],
          "title": "Requests per Service",
          "type": "timeseries"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "custom": {
                "axisCenteredZero": false,
                "axisColorMode": "text",
                "drawStyle": "line",
                "fillOpacity": 10,
                "lineWidth": 1,
                "showPoints": "never"
              },
              "unit": "percent"
            }
          },
          "gridPos": { "h": 8, "w": 12, "x": 12, "y": 4 },
          "id": 6,
          "targets": [
            {
              "expr": "sum(rate(container_cpu_usage_seconds_total{namespace=\"undateable\"}[5m])) by (pod) * 100",
              "legendFormat": "{{ pod }}",
              "refId": "A"
            }
          ],
          "title": "CPU Usage by Pod",
          "type": "timeseries"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "custom": {
                "drawStyle": "line",
                "fillOpacity": 10,
                "lineWidth": 1,
                "showPoints": "never"
              },
              "unit": "bytes"
            }
          },
          "gridPos": { "h": 8, "w": 12, "x": 0, "y": 12 },
          "id": 7,
          "targets": [
            {
              "expr": "sum(container_memory_usage_bytes{namespace=\"undateable\"}) by (pod)",
              "legendFormat": "{{ pod }}",
              "refId": "A"
            }
          ],
          "title": "Memory Usage by Pod",
          "type": "timeseries"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "fieldConfig": {
            "defaults": {
              "color": { "mode": "palette-classic" },
              "custom": {
                "drawStyle": "line",
                "fillOpacity": 10,
                "lineWidth": 1,
                "showPoints": "never"
              },
              "unit": "s"
            }
          },
          "gridPos": { "h": 8, "w": 12, "x": 12, "y": 12 },
          "id": 8,
          "targets": [
            {
              "expr": "histogram_quantile(0.95, sum(rate(nginx_ingress_controller_request_duration_seconds_bucket{namespace=\"undateable\"}[5m])) by (le, service))",
              "legendFormat": "{{ service }}",
              "refId": "A"
            }
          ],
          "title": "P95 Latency by Service",
          "type": "timeseries"
        }
      ],
      "refresh": "30s",
      "schemaVersion": 38,
      "style": "dark",
      "tags": ["undateable", "overview"],
      "templating": { "list": [] },
      "time": { "from": "now-1h", "to": "now" },
      "timepicker": {},
      "timezone": "",
      "title": "Undateable.me Overview",
      "uid": "undateable-overview",
      "version": 1,
      "weekStart": ""
    }
