{
  "dashboard": {
    "id": null,
    "uid": "mockupaws-overview",
    "title": "mockupAWS - Overview",
    "tags": ["mockupaws", "overview"],
    "timezone": "UTC",
    "schemaVersion": 36,
    "version": 1,
    "refresh": "30s",
    "annotations": {
      "list": [
        {
          "builtIn": 1,
          "datasource": {
            "type": "grafana",
            "uid": "-- Grafana --"
          },
          "enable": true,
          "hide": true,
          "iconColor": "rgba(0, 211, 255, 1)",
          "name": "Annotations & Alerts",
          "type": "dashboard"
        }
      ]
    },
    "templating": {
      "list": [
        {
          "name": "environment",
          "type": "constant",
          "current": {
            "value": "production",
            "text": "production"
          },
          "hide": 0
        },
        {
          "name": "service",
          "type": "query",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "query": "label_values(up{job=~\"mockupaws-.*\"}, job)",
          "refresh": 1,
          "hide": 0
        }
      ]
    },
    "panels": [
      {
        "id": 1,
        "title": "Uptime (30d)",
        "type": "stat",
        "targets": [
          {
            "expr": "avg_over_time(up{job=\"mockupaws-backend\"}[30d]) * 100",
            "legendFormat": "Uptime %",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percent",
            "min": 99,
            "max": 100,
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "red", "value": null},
                {"color": "yellow", "value": 99.9},
                {"color": "green", "value": 99.95}
              ]
            }
          }
        },
        "gridPos": {"h": 4, "w": 4, "x": 0, "y": 0}
      },
      {
        "id": 2,
        "title": "Requests/sec",
        "type": "stat",
        "targets": [
          {
            "expr": "sum(rate(http_requests_total{job=\"mockupaws-backend\"}[5m]))",
            "legendFormat": "RPS",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "reqps"
          }
        },
        "gridPos": {"h": 4, "w": 4, "x": 4, "y": 0}
      },
      {
        "id": 3,
        "title": "Error Rate",
        "type": "stat",
        "targets": [
          {
            "expr": "sum(rate(http_requests_total{job=\"mockupaws-backend\",status=~\"5..\"}[5m])) / sum(rate(http_requests_total{job=\"mockupaws-backend\"}[5m])) * 100",
            "legendFormat": "Error %",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percent",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 0.1},
                {"color": "red", "value": 1}
              ]
            }
          }
        },
        "gridPos": {"h": 4, "w": 4, "x": 8, "y": 0}
      },
      {
        "id": 4,
        "title": "Latency p50",
        "type": "stat",
        "targets": [
          {
            "expr": "histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket{job=\"mockupaws-backend\"}[5m])) by (le)) * 1000",
            "legendFormat": "p50",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "ms",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 200},
                {"color": "red", "value": 500}
              ]
            }
          }
        },
        "gridPos": {"h": 4, "w": 4, "x": 12, "y": 0}
      },
      {
        "id": 5,
        "title": "Latency p95",
        "type": "stat",
        "targets": [
          {
            "expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{job=\"mockupaws-backend\"}[5m])) by (le)) * 1000",
            "legendFormat": "p95",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "ms",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 500},
                {"color": "red", "value": 1000}
              ]
            }
          }
        },
        "gridPos": {"h": 4, "w": 4, "x": 16, "y": 0}
      },
      {
        "id": 6,
        "title": "Active Scenarios",
        "type": "stat",
        "targets": [
          {
            "expr": "scenarios_active_total",
            "legendFormat": "Active",
            "refId": "A"
          }
        ],
        "gridPos": {"h": 4, "w": 4, "x": 20, "y": 0}
      },
      {
        "id": 7,
        "title": "Request Rate Over Time",
        "type": "timeseries",
        "targets": [
          {
            "expr": "sum(rate(http_requests_total{job=\"mockupaws-backend\"}[5m])) by (status)",
            "legendFormat": "{{status}}",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "reqps"
          }
        },
        "options": {
          "legend": {
            "displayMode": "table",
            "placement": "right",
            "calcs": ["mean", "max"]
          }
        },
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 4}
      },
      {
        "id": 8,
        "title": "Response Time Percentiles",
        "type": "timeseries",
        "targets": [
          {
            "expr": "histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket{job=\"mockupaws-backend\"}[5m])) by (le)) * 1000",
            "legendFormat": "p50",
            "refId": "A"
          },
          {
            "expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{job=\"mockupaws-backend\"}[5m])) by (le)) * 1000",
            "legendFormat": "p95",
            "refId": "B"
          },
          {
            "expr": "histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket{job=\"mockupaws-backend\"}[5m])) by (le)) * 1000",
            "legendFormat": "p99",
            "refId": "C"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "ms",
            "custom": {
              "lineWidth": 2,
              "fillOpacity": 10
            }
          }
        },
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 4}
      },
      {
        "id": 9,
        "title": "Error Rate Over Time",
        "type": "timeseries",
        "targets": [
          {
            "expr": "sum(rate(http_requests_total{job=\"mockupaws-backend\",status=~\"5..\"}[5m])) / sum(rate(http_requests_total{job=\"mockupaws-backend\"}[5m])) * 100",
            "legendFormat": "5xx Error %",
            "refId": "A"
          },
          {
            "expr": "sum(rate(http_requests_total{job=\"mockupaws-backend\",status=~\"4..\"}[5m])) / sum(rate(http_requests_total{job=\"mockupaws-backend\"}[5m])) * 100",
            "legendFormat": "4xx Error %",
            "refId": "B"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percent"
          }
        },
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 12}
      },
      {
        "id": 10,
        "title": "Top Endpoints by Latency",
        "type": "table",
        "targets": [
          {
            "expr": "topk(10, histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{job=\"mockupaws-backend\"}[5m])) by (handler, le)))",
            "format": "table",
            "instant": true,
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "s"
          },
          "overrides": [
            {
              "matcher": {"id": "byName", "options": "Value"},
              "properties": [
                {"id": "displayName", "value": "p95 Latency"},
                {"id": "unit", "value": "ms"}
              ]
            }
          ]
        },
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 12}
      },
      {
        "id": 11,
        "title": "Infrastructure - CPU Usage",
        "type": "timeseries",
        "datasource": {
          "type": "prometheus",
          "uid": "prometheus"
        },
        "targets": [
          {
            "expr": "100 - (avg by (instance) (irate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)",
            "legendFormat": "{{instance}}",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percent",
            "min": 0,
            "max": 100,
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 70},
                {"color": "red", "value": 85}
              ]
            }
          }
        },
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 20}
      },
      {
        "id": 12,
        "title": "Infrastructure - Memory Usage",
        "type": "timeseries",
        "datasource": {
          "type": "prometheus",
          "uid": "prometheus"
        },
        "targets": [
          {
            "expr": "(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100",
            "legendFormat": "{{instance}}",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percent",
            "min": 0,
            "max": 100,
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 70},
                {"color": "red", "value": 85}
              ]
            }
          }
        },
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 20}
      }
    ]
  }
}
