{
  "__inputs": [
    {
      "description": "Prometheus data source that scrapes the SGLang server",
      "label": "Prometheus",
      "name": "DS_PROMETHEUS",
      "pluginId": "prometheus",
      "pluginName": "Prometheus",
      "query": "prometheus",
      "regex": "",
      "type": "datasource"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "10.4.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "10.4.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Timeseries",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": []
  },
  "description": "SGLang inference server: latency (TTFT/E2E/queue/TPOT), prefill & decode throughput, KV cache, requests, GPU memory, speculative decoding.",
  "editable": true,
  "graphTooltip": 1,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "type": "row",
      "collapsed": false,
      "id": 1,
      "panels": [],
      "title": "Overview",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      }
    },
    {
      "type": "stat",
      "id": 2,
      "title": "Running Requests",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Requests currently in the decode/batching loop (sglang:num_running_reqs).",
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 0,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:num_running_reqs{model_name=~\"$model_name\"})",
          "legendFormat": "",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 3,
      "title": "Queued Requests",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Requests waiting in the queue (sglang:num_queue_reqs).",
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 4,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:num_queue_reqs{model_name=~\"$model_name\"})",
          "legendFormat": "",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 4,
      "title": "Active HTTP Requests",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "HTTP requests currently in flight (sglang:http_requests_active).",
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 8,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:http_requests_active{model_name=~\"$model_name\"})",
          "legendFormat": "",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 5,
      "title": "Requests / s (5m)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Completion rate of requests over the last 5 minutes.",
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 12,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:num_requests_total{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 6,
      "title": "Retracted Reqs",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Requests currently retracted by the scheduler under KV cache pressure (sglang:num_retracted_reqs, gauge).",
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 16,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:num_retracted_reqs{model_name=~\"$model_name\"})",
          "legendFormat": "",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 7,
      "title": "Paused Requests",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Requests paused by the scheduler (sglang:num_paused_reqs, gauge).",
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 20,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:num_paused_reqs{model_name=~\"$model_name\"})",
          "legendFormat": "",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 8,
      "panels": [],
      "title": "Latency - TTFT / E2E / Queue / TPOT",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 6
      }
    },
    {
      "type": "stat",
      "id": 9,
      "title": "TTFT (Time to First Token)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Latency statistics for sglang:time_to_first_token_seconds. avg = mean over last 30m, current = mean over last 5m, max = p99 over last 30m.",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 0,
        "y": 7
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": "1"
              },
              {
                "color": "red",
                "value": "3"
              }
            ]
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:time_to_first_token_seconds_sum{model_name=~\"$model_name\"}[30m])) / sum(rate(sglang:time_to_first_token_seconds_count{model_name=~\"$model_name\"}[30m]))",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:time_to_first_token_seconds_sum{model_name=~\"$model_name\"}[5m])) / sum(rate(sglang:time_to_first_token_seconds_count{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le) (rate(sglang:time_to_first_token_seconds_bucket{model_name=~\"$model_name\"}[30m])))",
          "legendFormat": "max p99 (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 10,
      "title": "E2E Request Latency",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Latency statistics for sglang:e2e_request_latency_seconds. avg = mean over last 30m, current = mean over last 5m, max = p99 over last 30m.",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 6,
        "y": 7
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:e2e_request_latency_seconds_sum{model_name=~\"$model_name\"}[30m])) / sum(rate(sglang:e2e_request_latency_seconds_count{model_name=~\"$model_name\"}[30m]))",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:e2e_request_latency_seconds_sum{model_name=~\"$model_name\"}[5m])) / sum(rate(sglang:e2e_request_latency_seconds_count{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le) (rate(sglang:e2e_request_latency_seconds_bucket{model_name=~\"$model_name\"}[30m])))",
          "legendFormat": "max p99 (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 11,
      "title": "Queue Time",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Latency statistics for sglang:queue_time_seconds. avg = mean over last 30m, current = mean over last 5m, max = p99 over last 30m.",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 12,
        "y": 7
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:queue_time_seconds_sum{model_name=~\"$model_name\"}[30m])) / sum(rate(sglang:queue_time_seconds_count{model_name=~\"$model_name\"}[30m]))",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:queue_time_seconds_sum{model_name=~\"$model_name\"}[5m])) / sum(rate(sglang:queue_time_seconds_count{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le) (rate(sglang:queue_time_seconds_bucket{model_name=~\"$model_name\"}[30m])))",
          "legendFormat": "max p99 (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 12,
      "title": "TPOT (Per Output Token)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Latency statistics for sglang:inter_token_latency_seconds. avg = mean over last 30m, current = mean over last 5m, max = p99 over last 30m.",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 18,
        "y": 7
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:inter_token_latency_seconds_sum{model_name=~\"$model_name\"}[30m])) / sum(rate(sglang:inter_token_latency_seconds_count{model_name=~\"$model_name\"}[30m]))",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:inter_token_latency_seconds_sum{model_name=~\"$model_name\"}[5m])) / sum(rate(sglang:inter_token_latency_seconds_count{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le) (rate(sglang:inter_token_latency_seconds_bucket{model_name=~\"$model_name\"}[30m])))",
          "legendFormat": "max p99 (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 13,
      "title": "TTFT Percentiles",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "p50/p95/p99 time to first token, 5m window.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 12
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.5, sum by (le, model_name) (rate(sglang:time_to_first_token_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "p50 {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.95, sum by (le, model_name) (rate(sglang:time_to_first_token_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "p95 {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le, model_name) (rate(sglang:time_to_first_token_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "p99 {{model_name}}",
          "refId": "C"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 14,
      "title": "E2E & Queue Latency",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "End-to-end and queue-time percentiles, 5m window.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 12
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.95, sum by (le, model_name) (rate(sglang:e2e_request_latency_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "e2e p95 {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le, model_name) (rate(sglang:e2e_request_latency_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "e2e p99 {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.95, sum by (le, model_name) (rate(sglang:queue_time_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "queue p95 {{model_name}}",
          "refId": "C"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 15,
      "panels": [],
      "title": "Prefill & Decode",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 20
      }
    },
    {
      "type": "stat",
      "id": 16,
      "title": "Prefill Latency",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Latency of the prefill forward stage (sglang:per_stage_req_latency_seconds, stage=prefill_forward).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 0,
        "y": 21
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:per_stage_req_latency_seconds_sum{model_name=~\"$model_name\", stage=\"prefill_forward\"}[30m])) / sum(rate(sglang:per_stage_req_latency_seconds_count{model_name=~\"$model_name\", stage=\"prefill_forward\"}[30m]))",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:per_stage_req_latency_seconds_sum{model_name=~\"$model_name\", stage=\"prefill_forward\"}[5m])) / sum(rate(sglang:per_stage_req_latency_seconds_count{model_name=~\"$model_name\", stage=\"prefill_forward\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by (le) (rate(sglang:per_stage_req_latency_seconds_bucket{model_name=~\"$model_name\", stage=\"prefill_forward\"}[30m])))",
          "legendFormat": "max p99 (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 17,
      "title": "Prefill Throughput",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Prompt tokens processed per second (derived from sglang:prompt_tokens_total).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 8,
        "y": 21
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(increase(sglang:prompt_tokens_total{model_name=~\"$model_name\"}[30m])) / 1800",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:prompt_tokens_total{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(max_over_time(sum(rate(sglang:prompt_tokens_total{model_name=~\"$model_name\"}[5m]))[30m:5m]))",
          "legendFormat": "max (30m peak)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 18,
      "title": "Decode Throughput",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Generated tokens per second (derived from sglang:generation_tokens_total).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 16,
        "y": 21
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(increase(sglang:generation_tokens_total{model_name=~\"$model_name\"}[30m])) / 1800",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:generation_tokens_total{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "current (5m)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(max_over_time(sum(rate(sglang:generation_tokens_total{model_name=~\"$model_name\"}[5m]))[30m:5m]))",
          "legendFormat": "max (30m peak)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 19,
      "title": "Throughput (tok/s)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "gen_throughput gauge plus prompt/decode token rates.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 26
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:gen_throughput{model_name=~\"$model_name\"})",
          "legendFormat": "gen {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(rate(sglang:prompt_tokens_total{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "prefill {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(rate(sglang:generation_tokens_total{model_name=~\"$model_name\"}[5m]))",
          "legendFormat": "decode {{model_name}}",
          "refId": "C"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 20,
      "title": "Per-Stage Latency",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Percentiles per stage: chunked_prefill, prefill_forward, request_process.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 26
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "s",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.5, sum by (le, stage) (rate(sglang:per_stage_req_latency_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "p50 {{stage}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.95, sum by (le, stage) (rate(sglang:per_stage_req_latency_seconds_bucket{model_name=~\"$model_name\"}[5m])))",
          "legendFormat": "p95 {{stage}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 21,
      "panels": [],
      "title": "KV Cache & Tokens",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 34
      }
    },
    {
      "type": "stat",
      "id": 22,
      "title": "KV Cache Usage",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "KV cache token usage as a percentage (sglang:token_usage).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 0,
        "y": 35
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": "80"
              },
              {
                "color": "red",
                "value": "95"
              }
            ]
          },
          "unit": "percent",
          "decimals": 1,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(avg_over_time(sglang:token_usage{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(sglang:token_usage{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "current",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(max_over_time(sglang:token_usage{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "max (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 23,
      "title": "Radix Cache Hit Rate",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Radix-tree prefix cache hit rate (sglang:cache_hit_rate).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 8,
        "y": 35
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "percent",
          "decimals": 1,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(avg_over_time(sglang:cache_hit_rate{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(sglang:cache_hit_rate{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "current",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(max_over_time(sglang:cache_hit_rate{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "max (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 24,
      "title": "KV Tokens",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Used vs total KV tokens (sglang:kv_used_tokens / sglang:max_total_num_tokens).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 16,
        "y": 35
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:kv_used_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "used",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:max_total_num_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "capacity",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 25,
      "title": "KV Tokens",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "KV cache token usage over time.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 40
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:kv_used_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "used {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:kv_available_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "available {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:max_total_num_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "capacity {{model_name}}",
          "refId": "C"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 26,
      "title": "Cache Hit Rate %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Radix cache hit rate over time.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 40
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "percent",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg by (model_name)(sglang:cache_hit_rate{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "hit rate {{model_name}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 27,
      "panels": [],
      "title": "GPU Memory",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 48
      }
    },
    {
      "type": "timeseries",
      "id": 28,
      "title": "Memory (GB)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "GPU memory split: KV cache, CUDA graphs, model weights.",
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 49
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "GB",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:kv_cache_memory_usage_gb{model_name=~\"$model_name\"})",
          "legendFormat": "kv cache {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:graph_memory_usage_gb{model_name=~\"$model_name\"})",
          "legendFormat": "cuda graphs {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:weight_memory_usage_gb{model_name=~\"$model_name\"})",
          "legendFormat": "weights {{model_name}}",
          "refId": "C"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max by (instance)(sglang:startup_available_gpu_memory_gb{model_name=~\"$model_name\"})",
          "legendFormat": "available at startup {{instance}}",
          "refId": "D"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 34,
      "panels": [],
      "title": "Mamba / SSM Cache",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 57
      }
    },
    {
      "type": "stat",
      "id": 35,
      "title": "Mamba Cache Usage %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Mamba / SSM state cache usage as a percentage (sglang:mamba_usage). Only hybrid Mamba models report this.",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 0,
        "y": 58
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": "80"
              },
              {
                "color": "red",
                "value": "95"
              }
            ]
          },
          "unit": "percent",
          "decimals": 1,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(avg_over_time(sglang:mamba_usage{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(sglang:mamba_usage{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "current",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(max_over_time(sglang:mamba_usage{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "max (30m)",
          "refId": "C"
        }
      ]
    },
    {
      "type": "stat",
      "id": 36,
      "title": "Mamba Slots",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Mamba / SSM state slots: used vs available vs evictable (sglang:mamba_*_tokens).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 8,
        "y": 58
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:mamba_used_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "used",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:mamba_available_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "available",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:mamba_evictable_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "evictable",
          "refId": "C"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 37,
      "title": "Mamba / SSM Tokens",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Mamba / SSM state slots over time (only hybrid Mamba models report this).",
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 63
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:mamba_used_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "used {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:mamba_available_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "available {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (model_name)(sglang:mamba_evictable_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "evictable {{model_name}}",
          "refId": "C"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 38,
      "panels": [],
      "title": "HTTP & Errors",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 71
      }
    },
    {
      "type": "timeseries",
      "id": 39,
      "title": "HTTP Requests / s",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Inbound HTTP request rate (sglang:http_requests_total). This metric has no model_name label, so it is not filtered by $model_name.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 72
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "reqps",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(sglang:http_requests_total[5m]))",
          "legendFormat": "total",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (method)(rate(sglang:http_requests_total[5m]))",
          "legendFormat": "{{method}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 40,
      "title": "HTTP Errors / s (4xx / 5xx)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Error responses by status code and endpoint (sglang:http_responses_total; no model_name label).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 72
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "reqps",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (status_code, endpoint)(rate(sglang:http_responses_total{status_code=~\"4..|5..\"}[5m]))",
          "legendFormat": "HTTP {{status_code}} {{endpoint}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 41,
      "panels": [],
      "title": "Cache & Eviction",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 80
      }
    },
    {
      "type": "stat",
      "id": 42,
      "title": "Evicted (5m)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Prefix cache tokens evicted in the last 5 minutes, by cache type (sglang:evicted_tokens_total; no model_name label).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 0,
        "y": 81
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (cache_type)(increase(sglang:evicted_tokens_total[5m]))",
          "legendFormat": "{{cache_type}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 43,
      "title": "Cached / s (device)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Prompt tokens served from the device prefix cache, average per second over 5m (sglang:cached_tokens_total, cache_source=device).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 8,
        "y": 81
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(increase(sglang:cached_tokens_total{model_name=~\"$model_name\", cache_source=\"device\"}[5m])) / 5",
          "legendFormat": "tok/s",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 44,
      "title": "Cached / s (host)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Prompt tokens served from host memory (HiCache), average per second over 5m (sglang:cached_tokens_total, cache_source=host).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 16,
        "y": 81
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(increase(sglang:cached_tokens_total{model_name=~\"$model_name\", cache_source=\"host\"}[5m])) / 5",
          "legendFormat": "tok/s",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 45,
      "panels": [],
      "title": "HiCache (Host Memory)",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 86
      }
    },
    {
      "type": "stat",
      "id": 46,
      "title": "Host Usage %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "HiCache host memory tier occupancy (sglang:hicache_host_used_tokens / sglang:hicache_host_total_tokens).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 0,
        "y": 87
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": 80
              },
              {
                "color": "red",
                "value": 95
              }
            ]
          },
          "unit": "percent",
          "decimals": 1,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:hicache_host_used_tokens{model_name=~\"$model_name\"}) / sum(sglang:hicache_host_total_tokens{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "current",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 47,
      "title": "Dropped (5m)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "HiCache tokens dropped (data loss) in the last 5 minutes (sglang:hicache_dropped_tokens_total; no model_name label). Should stay at 0.",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 8,
        "y": 87
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(increase(sglang:hicache_dropped_tokens_total[5m]))",
          "legendFormat": "dropped",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 48,
      "title": "Host Tokens",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Used vs total tokens in the host memory tier (sglang:hicache_host_used_tokens / hicache_host_total_tokens).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 16,
        "y": 87
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:hicache_host_used_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "used",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(sglang:hicache_host_total_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "capacity",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 49,
      "title": "Backup / Load-back (tok/s)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Host <-> device cache traffic (sglang:hicache_backup_tokens_total, sglang:load_back_tokens_total; labelled by pool/cache_type, no model_name).",
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 92
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (pool, cache_type)(rate(sglang:hicache_backup_tokens_total[5m]))",
          "legendFormat": "backup {{pool}}/{{cache_type}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (pool, cache_type)(rate(sglang:load_back_tokens_total[5m]))",
          "legendFormat": "load-back {{pool}}/{{cache_type}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 50,
      "panels": [],
      "title": "GPU (NVIDIA / DCGM)",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 100
      }
    },
    {
      "type": "stat",
      "id": 51,
      "title": "GPU Util %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Peak GPU utilization across all GPUs (DCGM_FI_DEV_GPU_UTIL). No model_name label.",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 0,
        "y": 101
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(DCGM_FI_DEV_GPU_UTIL{job=\"dcgm_exporter\"})",
          "legendFormat": "max",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 52,
      "title": "GPU VRAM (GB)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Framebuffer memory used vs free (DCGM_FI_DEV_FB_USED / FB_FREE, MB on DCGM exporter, shown in GB).",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 6,
        "y": 101
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "GB",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_FB_USED{job=\"dcgm_exporter\"} / 1024",
          "legendFormat": "used",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_FB_FREE{job=\"dcgm_exporter\"} / 1024",
          "legendFormat": "free",
          "refId": "B"
        }
      ]
    },
    {
      "type": "stat",
      "id": 53,
      "title": "GPU Temp (°C)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Peak GPU core temperature (DCGM_FI_DEV_GPU_TEMP).",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 12,
        "y": 101
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": 83
              },
              {
                "color": "red",
                "value": 90
              }
            ]
          },
          "unit": "celsius",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(DCGM_FI_DEV_GPU_TEMP{job=\"dcgm_exporter\"})",
          "legendFormat": "max",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 54,
      "title": "GPU Power (W)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Total GPU power draw (DCGM_FI_DEV_POWER_USAGE, watts).",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 18,
        "y": 101
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "watt",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(DCGM_FI_DEV_POWER_USAGE{job=\"dcgm_exporter\"})",
          "legendFormat": "total",
          "refId": "A"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 55,
      "title": "GPU Utilization %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Per-GPU utilization over time (DCGM_FI_DEV_GPU_UTIL).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 106
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_GPU_UTIL{job=\"dcgm_exporter\"}",
          "legendFormat": "gpu {{gpu}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 56,
      "title": "GPU VRAM (GB)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Framebuffer used vs free over time (DCGM_FI_DEV_FB_USED / FB_FREE).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 106
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "GB",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_FB_USED{job=\"dcgm_exporter\"} / 1024",
          "legendFormat": "used gpu{{gpu}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_FB_FREE{job=\"dcgm_exporter\"} / 1024",
          "legendFormat": "free gpu{{gpu}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 64,
      "title": "GPU Clocks (MHz)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "SM and memory clocks (DCGM_FI_DEV_SM_CLOCK / MEM_CLOCK). A sustained drop under load = thermal/clock throttling.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 114
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "MHz",
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_SM_CLOCK{job=\"dcgm_exporter\"}",
          "legendFormat": "sm gpu{{gpu}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_MEM_CLOCK{job=\"dcgm_exporter\"}",
          "legendFormat": "mem gpu{{gpu}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 65,
      "title": "GPU Engine Activity %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Tensor / graphics-engine / DRAM active fractions (DCGM_FI_PROF_*) and H2D/D2H memory copy utilization (DCGM_FI_DEV_MEM_COPY_UTIL, high during HiCache backup/load-back).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 114
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(DCGM_FI_PROF_PIPE_TENSOR_ACTIVE{job=\"dcgm_exporter\"}[5m])) * 100",
          "legendFormat": "tensor %",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(DCGM_FI_PROF_GR_ENGINE_ACTIVE{job=\"dcgm_exporter\"}[5m])) * 100",
          "legendFormat": "gr engine %",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(DCGM_FI_PROF_DRAM_ACTIVE{job=\"dcgm_exporter\"}[5m])) * 100",
          "legendFormat": "dram %",
          "refId": "C"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "DCGM_FI_DEV_MEM_COPY_UTIL{job=\"dcgm_exporter\"}",
          "legendFormat": "mem copy util",
          "refId": "D"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 66,
      "title": "GPU PCIe (MB/s)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "PCIe host<->device bandwidth (DCGM_FI_PROF_PCIE_RX_BYTES / TX_BYTES). Sustained high = CPU/GPU data transfer bound.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 122
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "MBs",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(DCGM_FI_PROF_PCIE_RX_BYTES{job=\"dcgm_exporter\"}[5m])) / 1e6",
          "legendFormat": "rx",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(DCGM_FI_PROF_PCIE_TX_BYTES{job=\"dcgm_exporter\"}[5m])) / 1e6",
          "legendFormat": "tx",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 67,
      "title": "PCIe Replay / s",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "PCIe link replays per second (DCGM_FI_DEV_PCIE_REPLAY_COUNTER). Should stay ~0; spikes indicate link instability.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 122
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum(rate(DCGM_FI_DEV_PCIE_REPLAY_COUNTER{job=\"dcgm_exporter\"}[5m]))",
          "legendFormat": "replays/s",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 57,
      "panels": [],
      "title": "System (Host)",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 130
      }
    },
    {
      "type": "stat",
      "id": 58,
      "title": "CPU %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Host CPU usage, 5m average (node_exporter).",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 0,
        "y": 131
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": 80
              },
              {
                "color": "red",
                "value": 95
              }
            ]
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "100 - ((sum by (instance)(rate(node_cpu_seconds_total{job=\"node_exporter\", mode=\"idle\"}[5m])) / sum by (instance)(rate(node_cpu_seconds_total{job=\"node_exporter\", mode!=\"total\"}[5m]))) * 100)",
          "legendFormat": "usage",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 59,
      "title": "RAM Used %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Host memory used (total - available), node_exporter. Note: HiCache host pool counts inside this.",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 6,
        "y": 131
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": 80
              },
              {
                "color": "red",
                "value": 95
              }
            ]
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "(1 - (node_memory_MemAvailable_bytes{job=\"node_exporter\"} / node_memory_MemTotal_bytes{job=\"node_exporter\"})) * 100",
          "legendFormat": "used",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 60,
      "title": "Load (1m)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Host 1-minute load average (node_load1).",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 12,
        "y": 131
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "node_load1{job=\"node_exporter\"}",
          "legendFormat": "load1",
          "refId": "A"
        }
      ]
    },
    {
      "type": "stat",
      "id": 61,
      "title": "Root FS Used %",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Root filesystem usage (node_filesystem, mountpoint=/).",
      "gridPos": {
        "h": 5,
        "w": 6,
        "x": 18,
        "y": 131
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              },
              {
                "color": "yellow",
                "value": 80
              },
              {
                "color": "red",
                "value": 95
              }
            ]
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 0
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "(1 - (node_filesystem_avail_bytes{job=\"node_exporter\", mountpoint=\"/\"} / node_filesystem_size_bytes{job=\"node_exporter\", mountpoint=\"/\"})) * 100",
          "legendFormat": "used",
          "refId": "A"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 62,
      "title": "CPU % & Load",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Host CPU usage with load averages over time.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 136
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "100 - ((sum by (instance)(rate(node_cpu_seconds_total{job=\"node_exporter\", mode=\"idle\"}[5m])) / sum by (instance)(rate(node_cpu_seconds_total{job=\"node_exporter\", mode!=\"total\"}[5m]))) * 100)",
          "legendFormat": "cpu %",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "node_load1{job=\"node_exporter\"}",
          "legendFormat": "load1",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "node_load5{job=\"node_exporter\"}",
          "legendFormat": "load5",
          "refId": "C"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "node_load15{job=\"node_exporter\"}",
          "legendFormat": "load15",
          "refId": "D"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 63,
      "title": "Host Memory (GB)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Host RAM: used (total - available) vs available. HiCache host pool is part of used memory.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 136
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "GB",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "(node_memory_MemTotal_bytes{job=\"node_exporter\"} - node_memory_MemAvailable_bytes{job=\"node_exporter\"}) / 1e9",
          "legendFormat": "used",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "node_memory_MemAvailable_bytes{job=\"node_exporter\"} / 1e9",
          "legendFormat": "available",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 68,
      "title": "Disk I/O (B/s)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Block device read/write throughput (node_disk_read/written_bytes_total; loop/ram/dm filtered out).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 144
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "Bps",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (device)(rate(node_disk_read_bytes_total{job=\"node_exporter\", device!~\"loop.*|ram.*|dm-.*\"}[5m]))",
          "legendFormat": "read {{device}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (device)(rate(node_disk_written_bytes_total{job=\"node_exporter\", device!~\"loop.*|ram.*|dm-.*\"}[5m]))",
          "legendFormat": "write {{device}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 69,
      "title": "Network I/O (B/s)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Network throughput per interface (node_network_receive/transmit_bytes_total; lo/veth/bridge/docker noise filtered).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 144
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "Bps",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (device)(rate(node_network_receive_bytes_total{job=\"node_exporter\", device!~\"lo|veth.*|br-.*|docker.*\"}[5m]))",
          "legendFormat": "rx {{device}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (device)(rate(node_network_transmit_bytes_total{job=\"node_exporter\", device!~\"lo|veth.*|br-.*|docker.*\"}[5m]))",
          "legendFormat": "tx {{device}}",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 70,
      "title": "Disk Usage % (mountpoints)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Used percentage per real mountpoint (node_filesystem; tmpfs excluded).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 152
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "percent",
          "decimals": 0,
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "(1 - (node_filesystem_avail_bytes{job=\"node_exporter\", fstype!~\"tmpfs\"} / node_filesystem_size_bytes{job=\"node_exporter\", fstype!~\"tmpfs\"})) * 100",
          "legendFormat": "used {{mountpoint}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 71,
      "title": "Sensor Temps (°C)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Hardware (hwmon) sensor temps incl. NVMe (node_hwmon_temp_celsius).",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 152
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "celsius",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "node_hwmon_temp_celsius{job=\"node_exporter\"}",
          "legendFormat": "{{sensor}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "id": 29,
      "panels": [],
      "title": "Speculative Decoding (MTP)",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 160
      }
    },
    {
      "type": "stat",
      "id": 30,
      "title": "Spec Accept Rate",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Share of speculative draft tokens accepted (sglang:spec_accept_rate).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 0,
        "y": 161
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "percent",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(avg_over_time(sglang:spec_accept_rate{model_name=~\"$model_name\"}[30m:1m])) * 100",
          "legendFormat": "avg (30m)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(sglang:spec_accept_rate{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "current",
          "refId": "B"
        }
      ]
    },
    {
      "type": "stat",
      "id": 31,
      "title": "Accepted Draft Length",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Average number of draft tokens accepted per step (sglang:spec_accept_length).",
      "gridPos": {
        "h": 5,
        "w": 8,
        "x": 8,
        "y": 161
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": "null"
              }
            ]
          },
          "unit": "short",
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "limits": {}
        },
        "textMode": "value_and_name",
        "decimals": 2
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max(sglang:spec_accept_length{model_name=~\"$model_name\"})",
          "legendFormat": "current",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "avg(avg_over_time(sglang:spec_accept_length{model_name=~\"$model_name\"}[30m:1m]))",
          "legendFormat": "avg (30m)",
          "refId": "B"
        }
      ]
    },
    {
      "type": "timeseries",
      "id": 32,
      "title": "Speculative Decoding",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Speculative decoding efficiency (only populated for MTP / EAGLE models).",
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 166
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisPlacement": "auto",
            "drawStyle": "line",
            "fillOpacity": 8,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "never",
            "spanNulls": false
          },
          "unit": "short",
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "mean"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max by (model_name)(sglang:spec_accept_rate{model_name=~\"$model_name\"}) * 100",
          "legendFormat": "accept rate % {{model_name}}",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max by (model_name)(sglang:spec_accept_length{model_name=~\"$model_name\"})",
          "legendFormat": "avg accepted {{model_name}}",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "max by (model_name)(sglang:spec_num_draft_tokens{model_name=~\"$model_name\"})",
          "legendFormat": "draft tokens {{model_name}}",
          "refId": "C"
        }
      ]
    },
    {
      "type": "text",
      "id": 33,
      "title": "About / metric reference",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 14,
        "w": 24,
        "x": 0,
        "y": 174
      },
      "options": {
        "code": {
          "language": "markdown",
          "showLineNumbers": false,
          "showMiniMap": false
        },
        "content": "## About this dashboard\n- **Prometheus variable** (top bar): selects which Prometheus data source / endpoint the panels query.\n  Create one under *Grafana > Configuration > Data sources* (URL `http://localhost:9090`),\n  then pick it on the import screen or in the variable dropdown afterwards.\n- **Model variable** (top bar): all queries are filtered by `model_name`. Pick one model or `All`.\n\n### Stat panels\n`avg` = average over the last 30m, `current` = current value (5m), `max` = p99 for latency histograms / 30m peak for gauges & throughput.\n\n### Metric reference (SGLang)\n| Panel | Metric(s) |\n|---|---|\n| TTFT | `sglang:time_to_first_token_seconds` |\n| E2E latency | `sglang:e2e_request_latency_seconds` |\n| Queue time | `sglang:queue_time_seconds` |\n| Decode per-token | `sglang:inter_token_latency_seconds` |\n| Prefill / per-stage | `sglang:per_stage_req_latency_seconds` (`chunked_prefill`, `prefill_forward`, `request_process`) |\n| Throughput | `sglang:gen_throughput`, `sglang:prompt_tokens_total`, `sglang:generation_tokens_total` |\n| Requests | `sglang:num_requests_total`, `sglang:num_running_reqs`, `sglang:num_queue_reqs`, `sglang:http_requests_active`, `sglang:num_retracted_requests_total`, `sglang:num_aborted_requests_total` |\n| KV cache | `sglang:token_usage`, `sglang:kv_used_tokens`, `sglang:kv_available_tokens`, `sglang:max_total_num_tokens`, `sglang:cache_hit_rate` |\n| GPU memory | `sglang:kv_cache_memory_usage_gb`, `sglang:graph_memory_usage_gb`, `sglang:weight_memory_usage_gb`, `sglang:startup_available_gpu_memory_gb` |\n| Mamba / SSM cache | `sglang:mamba_usage`, `sglang:mamba_used_tokens`, `sglang:mamba_available_tokens`, `sglang:mamba_evictable_tokens` |\n| Speculative decoding | `sglang:spec_accept_rate`, `sglang:spec_accept_length`, `sglang:spec_num_draft_tokens` |\n",
        "mode": "markdown",
        "wrap": true
      }
    }
  ],
  "refresh": "30s",
  "schemaVersion": 39,
  "tags": [
    "sglang",
    "llm",
    "inference",
    "prometheus"
  ],
  "templating": {
    "list": [
      {
        "current": {},
        "description": "Which Prometheus data source (endpoint) the panels query",
        "hide": 0,
        "label": "Prometheus",
        "name": "DS_PROMETHEUS",
        "query": "prometheus",
        "refresh": 1,
        "regex": "",
        "type": "datasource"
      },
      {
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "label_values(sglang:num_requests_total, model_name)",
        "hide": 0,
        "allValue": ".*",
        "current": {
          "selected": true,
          "text": "All",
          "value": "$__all"
        },
        "includeAll": true,
        "label": "Model",
        "multi": false,
        "name": "model_name",
        "query": "label_values(sglang:num_requests_total, model_name)",
        "refresh": 2,
        "regex": "",
        "sort": 1,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "browser",
  "title": "SGLang - Inference Server",
  "uid": "sglang-inference",
  "version": 1
}
