{
  "title": "Veylant Proxy — Overview",
  "uid": "veylant-proxy-overview",
  "schemaVersion": 38,
  "version": 1,
  "refresh": "15s",
  "panels": [
    {
      "id": 1,
      "title": "Requests per second",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
      "targets": [
        {
          "expr": "rate(veylant_requests_total[1m])",
          "legendFormat": "{{method}} {{path}} {{status}}"
        }
      ]
    },
    {
      "id": 2,
      "title": "Request duration p50/p95/p99 (seconds)",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
      "targets": [
        {
          "expr": "histogram_quantile(0.50, rate(veylant_request_duration_seconds_bucket[1m]))",
          "legendFormat": "p50"
        },
        {
          "expr": "histogram_quantile(0.95, rate(veylant_request_duration_seconds_bucket[1m]))",
          "legendFormat": "p95"
        },
        {
          "expr": "histogram_quantile(0.99, rate(veylant_request_duration_seconds_bucket[1m]))",
          "legendFormat": "p99"
        }
      ]
    },
    {
      "id": 3,
      "title": "Error rate",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
      "targets": [
        {
          "expr": "rate(veylant_request_errors_total[1m])",
          "legendFormat": "{{error_type}}"
        }
      ]
    },
    {
      "id": 4,
      "title": "Total requests (24h)",
      "type": "stat",
      "gridPos": { "h": 4, "w": 6, "x": 12, "y": 8 },
      "targets": [
        {
          "expr": "sum(increase(veylant_requests_total[24h]))",
          "legendFormat": "Total"
        }
      ]
    },
    {
      "id": 5,
      "title": "Error rate % (24h)",
      "type": "stat",
      "gridPos": { "h": 4, "w": 6, "x": 18, "y": 8 },
      "targets": [
        {
          "expr": "100 * sum(increase(veylant_request_errors_total[24h])) / sum(increase(veylant_requests_total[24h]))",
          "legendFormat": "Error %"
        }
      ]
    },
    {
      "id": 6,
      "title": "PII Entities Detected — Rate by Type",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 },
      "targets": [
        {
          "expr": "sum by (entity_type) (rate(veylant_pii_entities_detected_total[1m]))",
          "legendFormat": "{{ entity_type }}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": { "lineWidth": 2 }
        }
      }
    },
    {
      "id": 7,
      "title": "PostgreSQL Active Connections",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 16 },
      "targets": [
        {
          "expr": "veylant_db_connections_active",
          "legendFormat": "Active"
        },
        {
          "expr": "veylant_db_connections_idle",
          "legendFormat": "Idle"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        }
      }
    },
    {
      "id": 8,
      "title": "Provider Breakdown (RPS)",
      "type": "piechart",
      "gridPos": { "h": 8, "w": 8, "x": 0, "y": 24 },
      "options": {
        "pieType": "donut",
        "displayLabels": ["name", "percent"]
      },
      "targets": [
        {
          "expr": "sum by (provider) (rate(veylant_requests_total[5m]))",
          "legendFormat": "{{ provider }}"
        }
      ]
    }
  ],
  "schemaVersion": 38,
  "version": 2
}
