{
  "uid": "nexus-app",
  "title": "Nexus — Application",
  "tags": ["gunicorn", "flask"],
  "timezone": "browser",
  "schemaVersion": 36,
  "refresh": "30s",
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "templating": {
    "list": [
      {
        "name": "datasource",
        "type": "datasource",
        "query": "prometheus",
        "current": {
          "selected": false,
          "text": "Prometheus",
          "value": "Prometheus"
        }
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "title": "Request Rate (nginx)",
      "type": "timeseries",
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
      "datasource": {"type": "prometheus", "uid": "${datasource}"},
      "targets": [
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "expr": "rate(nginx_http_requests_total[5m])",
          "legendFormat": "Requests/sec",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {"drawStyle": "line", "lineWidth": 2, "fillOpacity": 10},
          "unit": "reqps",
          "min": 0
        },
        "overrides": []
      }
    },
    {
      "id": 2,
      "title": "Response Time (nginx)",
      "type": "timeseries",
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
      "datasource": {"type": "prometheus", "uid": "${datasource}"},
      "targets": [
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "expr": "histogram_quantile(0.95, sum(rate(nginx_http_request_duration_seconds_bucket[5m])) by (le))",
          "legendFormat": "p95",
          "refId": "A"
        },
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "expr": "histogram_quantile(0.99, sum(rate(nginx_http_request_duration_seconds_bucket[5m])) by (le))",
          "legendFormat": "p99",
          "refId": "B"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {"drawStyle": "line", "lineWidth": 2, "fillOpacity": 10},
          "unit": "s",
          "min": 0
        },
        "overrides": []
      }
    },
    {
      "id": 3,
      "title": "Active Workers",
      "type": "timeseries",
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 8},
      "datasource": {"type": "prometheus", "uid": "${datasource}"},
      "targets": [
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "expr": "count by (instance) (node_processes_state{state=\"S\", cmdline=~\".*gunicorn.*\"})",
          "legendFormat": "Workers {{instance}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {"drawStyle": "line", "lineWidth": 2, "fillOpacity": 10},
          "unit": "short",
          "min": 0
        },
        "overrides": []
      }
    },
    {
      "id": 4,
      "title": "5xx Errors",
      "type": "timeseries",
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 8},
      "datasource": {"type": "prometheus", "uid": "${datasource}"},
      "targets": [
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "expr": "rate(nginx_http_requests_total{status=~\"5..\"}[5m])",
          "legendFormat": "5xx/sec",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {"drawStyle": "line", "lineWidth": 2, "fillOpacity": 10},
          "unit": "reqps",
          "min": 0
        },
        "overrides": []
      }
    },
    {
      "id": 5,
      "title": "Memory per Worker",
      "type": "timeseries",
      "gridPos": {"h": 8, "w": 24, "x": 0, "y": 16},
      "datasource": {"type": "prometheus", "uid": "${datasource}"},
      "targets": [
        {
          "datasource": {"type": "prometheus", "uid": "${datasource}"},
          "expr": "process_resident_memory_bytes{cmdline=~\".*gunicorn.*\"} / 1024 / 1024",
          "legendFormat": "{{cmdline}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {"drawStyle": "line", "lineWidth": 2, "fillOpacity": 10},
          "unit": "mbytes",
          "min": 0
        },
        "overrides": []
      }
    }
  ]
}
