{
  "title": "Services Overview",
  "uid": "services-overview",
  "schemaVersion": 38,
  "version": 1,
  "refresh": "30s",
  "time": { "from": "now-1h", "to": "now" },
  "templating": {
    "list": [
      {
        "name": "service",
        "type": "query",
        "datasource": "Prometheus",
        "query": "label_values(http_requests_total, service)",
        "multi": true,
        "includeAll": true,
        "current": { "text": "All", "value": "$__all" }
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "title": "Request Rate (req/s)",
      "type": "timeseries",
      "gridPos": { "x": 0, "y": 0, "w": 12, "h": 8 },
      "targets": [
        {
          "expr": "sum(rate(http_requests_total{service=~\"$service\"}[5m])) by (service)",
          "legendFormat": "{{service}}"
        }
      ]
    },
    {
      "id": 2,
      "title": "Error Rate (%)",
      "type": "timeseries",
      "gridPos": { "x": 12, "y": 0, "w": 12, "h": 8 },
      "targets": [
        {
          "expr": "sum(rate(http_requests_total{service=~\"$service\", status_code=~\"5..\"}[5m])) by (service) / sum(rate(http_requests_total{service=~\"$service\"}[5m])) by (service) * 100",
          "legendFormat": "{{service}}"
        }
      ]
    },
    {
      "id": 3,
      "title": "Latency P50 (ms)",
      "type": "timeseries",
      "gridPos": { "x": 0, "y": 8, "w": 8, "h": 8 },
      "targets": [
        {
          "expr": "histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket{service=~\"$service\"}[5m])) by (service, le)) * 1000",
          "legendFormat": "{{service}} p50"
        }
      ]
    },
    {
      "id": 4,
      "title": "Latency P95 (ms)",
      "type": "timeseries",
      "gridPos": { "x": 8, "y": 8, "w": 8, "h": 8 },
      "targets": [
        {
          "expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{service=~\"$service\"}[5m])) by (service, le)) * 1000",
          "legendFormat": "{{service}} p95"
        }
      ]
    },
    {
      "id": 5,
      "title": "Latency P99 (ms)",
      "type": "timeseries",
      "gridPos": { "x": 16, "y": 8, "w": 8, "h": 8 },
      "targets": [
        {
          "expr": "histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket{service=~\"$service\"}[5m])) by (service, le)) * 1000",
          "legendFormat": "{{service}} p99"
        }
      ]
    },
    {
      "id": 6,
      "title": "Active Requests",
      "type": "timeseries",
      "gridPos": { "x": 0, "y": 16, "w": 12, "h": 8 },
      "targets": [
        {
          "expr": "sum(http_requests_in_progress{service=~\"$service\"}) by (service)",
          "legendFormat": "{{service}}"
        }
      ]
    }
  ]
}
