# k8s/monitoring/dashboards/control-plane-logs.yaml
# Surfaces controller/control-plane logs that are already in Loki today
# (Promtail scrapes every namespace with no filter) — this dashboard is the
# "make it visible" piece, not new log collection.
apiVersion: v1
kind: ConfigMap
metadata:
  name: control-plane-logs-dashboard
  namespace: logging
  labels:
    grafana_dashboard: "1"
data:
  control-plane-logs.json: |
    {
      "title": "Cluster Control Plane & Controllers (Logs)",
      "uid": "control-plane-logs",
      "schemaVersion": 39,
      "timezone": "browser",
      "time": { "from": "now-1h", "to": "now" },
      "refresh": "30s",
      "panels": [
        {
          "id": 1,
          "title": "Error rate by namespace",
          "type": "timeseries",
          "gridPos": { "h": 6, "w": 24, "x": 0, "y": 0 },
          "datasource": { "type": "loki", "uid": "loki" },
          "targets": [
            {
              "expr": "sum by (namespace) (count_over_time({namespace=~\"kube-system|cert-manager|ingress-nginx|longhorn-system\"} |= \"error\" [5m]))"
            }
          ]
        },
        {
          "id": 2,
          "title": "Control plane (kube-apiserver, controller-manager, scheduler)",
          "type": "logs",
          "gridPos": { "h": 10, "w": 24, "x": 0, "y": 6 },
          "datasource": { "type": "loki", "uid": "loki" },
          "targets": [
            { "expr": "{namespace=\"kube-system\"}" }
          ]
        },
        {
          "id": 3,
          "title": "Cluster add-ons (cert-manager, ingress-nginx, longhorn)",
          "type": "logs",
          "gridPos": { "h": 10, "w": 24, "x": 0, "y": 16 },
          "datasource": { "type": "loki", "uid": "loki" },
          "targets": [
            { "expr": "{namespace=~\"cert-manager|ingress-nginx|longhorn-system\"}" }
          ]
        }
      ]
    }
