{
  "uid": "shithubd-overview",
  "title": "shithubd — overview",
  "tags": ["shithubd"],
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "refresh": "30s",
  "time": {"from": "now-6h", "to": "now"},
  "templating": {
    "list": [
      {
        "name": "instance",
        "type": "query",
        "datasource": "Prometheus",
        "query": "label_values(up{job=\"shithubd-web\"}, instance)",
        "includeAll": true,
        "multi": true
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "stat",
      "title": "Web up",
      "gridPos": {"x": 0, "y": 0, "w": 4, "h": 4},
      "targets": [{"expr": "sum(up{job=\"shithubd-web\"})", "refId": "A"}]
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Worker up",
      "gridPos": {"x": 4, "y": 0, "w": 4, "h": 4},
      "targets": [{"expr": "sum(up{job=\"shithubd-worker\"})", "refId": "A"}]
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Postgres up",
      "gridPos": {"x": 8, "y": 0, "w": 4, "h": 4},
      "targets": [{"expr": "up{job=\"postgres\"}", "refId": "A"}]
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Job queue depth",
      "gridPos": {"x": 12, "y": 0, "w": 4, "h": 4},
      "targets": [{"expr": "shithubd_job_queue_depth", "refId": "A"}],
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {"color": "green", "value": null},
              {"color": "yellow", "value": 1000},
              {"color": "red", "value": 5000}
            ]
          }
        }
      }
    },
    {
      "id": 5,
      "type": "timeseries",
      "title": "Request rate by route",
      "gridPos": {"x": 0, "y": 4, "w": 12, "h": 8},
      "targets": [
        {
          "expr": "sum(rate(http_requests_total{instance=~\"$instance\"}[1m])) by (route)",
          "legendFormat": "{{route}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 6,
      "type": "timeseries",
      "title": "p95 latency by route",
      "gridPos": {"x": 12, "y": 4, "w": 12, "h": 8},
      "targets": [
        {
          "expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{instance=~\"$instance\"}[5m])) by (route, le))",
          "legendFormat": "{{route}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 7,
      "type": "timeseries",
      "title": "DB calls/sec",
      "gridPos": {"x": 0, "y": 12, "w": 12, "h": 8},
      "targets": [
        {
          "expr": "sum(rate(pg_stat_statements_calls_total[1m]))",
          "legendFormat": "calls/sec",
          "refId": "A"
        }
      ]
    },
    {
      "id": 8,
      "type": "timeseries",
      "title": "Webhook deliveries (success vs failure)",
      "gridPos": {"x": 12, "y": 12, "w": 12, "h": 8},
      "targets": [
        {
          "expr": "sum(rate(shithubd_webhook_deliveries_total[1m])) by (result)",
          "legendFormat": "{{result}}",
          "refId": "A"
        }
      ]
    }
  ]
}
