{
  "annotations": {
    "list": []
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "links": [
    {
      "asDropdown": false,
      "icon": "external link",
      "includeVars": true,
      "keepTime": true,
      "tags": ["llmhosts"],
      "targetBlank": false,
      "title": "LLMHosts Dashboards",
      "type": "dashboards"
    }
  ],
  "panels": [
    {
      "title": "Messages per Minute by Intent",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(rate(token_messages_total[5m])) by (intent) * 60",
          "legendFormat": "{{ intent }}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": { "drawStyle": "line", "fillOpacity": 10, "lineWidth": 2 }
        },
        "overrides": []
      }
    },
    {
      "title": "Cost over Time by Model (USD/min)",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(rate(token_cost_usd_total[5m])) by (model) * 60",
          "legendFormat": "{{ model }}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "currencyUSD",
          "custom": { "drawStyle": "line", "fillOpacity": 10, "lineWidth": 2 }
        },
        "overrides": []
      }
    },
    {
      "title": "Latency P50 / P95 / P99 (ms)",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "token_latency_ms{quantile=\"0.5\"}",
          "legendFormat": "P50 — {{ model }}"
        },
        {
          "expr": "token_latency_ms{quantile=\"0.95\"}",
          "legendFormat": "P95 — {{ model }}"
        },
        {
          "expr": "token_latency_ms{quantile=\"0.99\"}",
          "legendFormat": "P99 — {{ model }}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "ms",
          "custom": { "drawStyle": "line", "fillOpacity": 5, "lineWidth": 2 },
          "thresholds": {
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 1000 },
              { "color": "red", "value": 3000 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Active Alerts by Severity",
      "type": "stat",
      "gridPos": { "h": 8, "w": 6, "x": 12, "y": 8 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(token_alerts_total) by (severity)",
          "legendFormat": "{{ severity }}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 1 },
              { "color": "red", "value": 5 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Budget Utilization",
      "type": "text",
      "gridPos": { "h": 8, "w": 6, "x": 18, "y": 8 },
      "options": {
        "mode": "markdown",
        "content": "### Budget Tracking\n\nReal-time budget data is available at:\n\n**`GET /api/token/analytics`**\n\nThis includes monthly spend, budget used %, and per-model breakdowns.\n\nAlert thresholds:\n- **Warning**: >80% budget used\n- **Critical**: >95% budget used"
      }
    },
    {
      "title": "Total Messages by Model",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(rate(token_messages_total[5m])) by (model) * 60",
          "legendFormat": "{{ model }}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": { "drawStyle": "bars", "fillOpacity": 80, "lineWidth": 0, "stacking": { "mode": "normal" } }
        },
        "overrides": []
      }
    },
    {
      "title": "Total Cost (Cumulative USD)",
      "type": "stat",
      "gridPos": { "h": 8, "w": 6, "x": 12, "y": 16 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(token_cost_usd_total)",
          "legendFormat": "Total Cost"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "currencyUSD"
        },
        "overrides": []
      }
    },
    {
      "title": "Total Messages",
      "type": "stat",
      "gridPos": { "h": 8, "w": 6, "x": 18, "y": 16 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(token_messages_total)",
          "legendFormat": "Messages"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      }
    }
  ],
  "schemaVersion": 39,
  "tags": ["llmhosts", "token"],
  "templating": {
    "list": [
      {
        "name": "DS_PROMETHEUS",
        "type": "datasource",
        "query": "prometheus",
        "current": { "text": "Prometheus", "value": "Prometheus" }
      }
    ]
  },
  "time": { "from": "now-6h", "to": "now" },
  "timepicker": {},
  "timezone": "browser",
  "title": "LLMHosts Token",
  "uid": "llmhosts-token",
  "version": 1
}
