{
  "title": "Logs by Service (Dev)",
  "uid": "dev-logs-by-service",
  "tags": ["dev","logs","loki"],
  "time": { "from": "now-1h", "to": "now" },
  "schemaVersion": 42,
  "templating": {
    "list": [
      {
        "name": "service",
        "label": "Service (label app)",
        "type": "query",
        "datasource": "loki",
        "query": "label_values({app!=\"\"}, app)",
        "includeAll": true,
        "multi": true,
        "refresh": 2,
        "current": {}
      }
    ]
  },
  "panels": [
    {
      "type": "logs",
      "title": "Logs – $service",
      "gridPos": { "x": 0, "y": 0, "w": 24, "h": 12 },
      "datasource": "loki",
      "options": {
        "showLabels": true,
        "showTime": true,
        "wrapLogMessage": true,
        "prettifyLogMessage": true
      },
      "targets": [
        {
          "refId": "A",
          "expr": "{app=~\"$service\"}"
        }
      ]
    },
    {
      "type": "timeseries",
      "title": "Error rate (logs/min) – $service",
      "gridPos": { "x": 0, "y": 12, "w": 24, "h": 8 },
      "datasource": "loki",
      "fieldConfig": { "defaults": { "unit": "ops" }, "overrides": [] },
      "options": {
        "legend": { "showLegend": true, "placement": "bottom" }
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by (app)(rate({app=~\"$service\"} |~ \"(?i)(error|exception|fail|timeout)\"[5m])) * 60"
        }
      ]
    }
  ]
}
