{
  "title": "Logs – Ops (Errors & System)",
  "uid": "ops-logs-errors",
  "tags": ["ops","logs","loki"],
  "time": { "from": "now-2h", "to": "now" },
  "schemaVersion": 42,
  "templating": {
    "list": [
      {
        "name": "job",
        "label": "Job",
        "type": "query",
        "datasource": "loki",
        "query": "label_values(job)",
        "includeAll": true,
        "multi": true,
        "refresh": 2
      },
      {
        "name": "instance",
        "label": "Instance",
        "type": "query",
        "datasource": "loki",
        "query": "label_values({job=~\"$job\"}, instance)",
        "includeAll": true,
        "multi": true,
        "refresh": 2
      }
    ]
  },
  "panels": [
    {
      "type": "timeseries",
      "title": "Error rate by instance (logs/min)",
      "gridPos": { "x": 0, "y": 0, "w": 24, "h": 8 },
      "datasource": "loki",
      "fieldConfig": { "defaults": { "unit": "ops" }, "overrides": [] },
      "options": { "legend": { "showLegend": true, "placement": "bottom" } },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by (instance)(rate({job=~\"$job\", instance=~\"$instance\"} |~ \"(?i)(critical|error|err)\"[5m])) * 60"
        }
      ]
    },
    {
      "type": "logs",
      "title": "Recent critical & errors – $job / $instance",
      "gridPos": { "x": 0, "y": 8, "w": 24, "h": 14 },
      "datasource": "loki",
      "options": {
        "showLabels": true,
        "showTime": true,
        "wrapLogMessage": true,
        "prettifyLogMessage": true
      },
      "targets": [
        {
          "refId": "A",
          "expr": "{job=~\"$job\", instance=~\"$instance\"} |~ \"(?i)(critical|error|err|panic|oom)\""
        }
      ]
    }
  ]
}
