{
  "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": "Cache Hit Rate (Overall)",
      "type": "gauge",
      "gridPos": { "h": 8, "w": 8, "x": 0, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llmhost_cache_hit_rate",
          "legendFormat": "Hit Rate"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "min": 0,
          "max": 1,
          "thresholds": {
            "steps": [
              { "color": "red", "value": null },
              { "color": "orange", "value": 0.2 },
              { "color": "yellow", "value": 0.4 },
              { "color": "green", "value": 0.6 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Cache Hits",
      "type": "stat",
      "gridPos": { "h": 8, "w": 8, "x": 8, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llmhost_cache_hits_total",
          "legendFormat": "Total Hits"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": { "mode": "thresholds" },
          "thresholds": {
            "steps": [
              { "color": "green", "value": null }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Cache Misses",
      "type": "stat",
      "gridPos": { "h": 8, "w": 8, "x": 16, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llmhost_cache_misses_total",
          "legendFormat": "Total Misses"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": { "mode": "thresholds" },
          "thresholds": {
            "steps": [
              { "color": "orange", "value": null }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Cache Hits vs Misses Over Time",
      "type": "timeseries",
      "gridPos": { "h": 10, "w": 12, "x": 0, "y": 8 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(llmhost_cache_hits_total[5m])",
          "legendFormat": "Hits/s"
        },
        {
          "expr": "rate(llmhost_cache_misses_total[5m])",
          "legendFormat": "Misses/s"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "ops",
          "custom": { "drawStyle": "line", "fillOpacity": 15, "lineWidth": 2, "pointSize": 5 }
        },
        "overrides": [
          {
            "matcher": { "id": "byName", "options": "Hits/s" },
            "properties": [{ "id": "color", "value": { "fixedColor": "green", "mode": "fixed" } }]
          },
          {
            "matcher": { "id": "byName", "options": "Misses/s" },
            "properties": [{ "id": "color", "value": { "fixedColor": "red", "mode": "fixed" } }]
          }
        ]
      }
    },
    {
      "title": "Cache Hit Rate Over Time",
      "type": "timeseries",
      "gridPos": { "h": 10, "w": 12, "x": 12, "y": 8 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llmhost_cache_hit_rate",
          "legendFormat": "Hit Rate"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "min": 0,
          "max": 1,
          "custom": {
            "drawStyle": "line",
            "fillOpacity": 20,
            "lineWidth": 2,
            "thresholdsStyle": { "mode": "area" }
          },
          "thresholds": {
            "steps": [
              { "color": "red", "value": null },
              { "color": "yellow", "value": 0.3 },
              { "color": "green", "value": 0.6 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Savings from Cache (USD)",
      "type": "timeseries",
      "gridPos": { "h": 10, "w": 12, "x": 0, "y": 18 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llm_savings_usd_total",
          "legendFormat": "Total Savings"
        },
        {
          "expr": "rate(llm_savings_usd_total[5m]) * 3600",
          "legendFormat": "Savings/hr"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "currencyUSD",
          "custom": { "drawStyle": "line", "fillOpacity": 10, "lineWidth": 2 }
        },
        "overrides": [
          {
            "matcher": { "id": "byName", "options": "Savings/hr" },
            "properties": [
              { "id": "custom.drawStyle", "value": "bars" },
              { "id": "custom.fillOpacity", "value": 40 }
            ]
          }
        ]
      }
    },
    {
      "title": "Savings Percentage",
      "type": "gauge",
      "gridPos": { "h": 10, "w": 6, "x": 12, "y": 18 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llmhost_savings_percent / 100",
          "legendFormat": "Savings %"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "min": 0,
          "max": 1,
          "thresholds": {
            "steps": [
              { "color": "red", "value": null },
              { "color": "yellow", "value": 0.1 },
              { "color": "green", "value": 0.3 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "title": "Cached vs Uncached LLM Requests",
      "type": "timeseries",
      "gridPos": { "h": 10, "w": 6, "x": 18, "y": 18 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "sum(rate(llm_requests_total{cached=\"true\"}[5m]))",
          "legendFormat": "Cached"
        },
        {
          "expr": "sum(rate(llm_requests_total{cached=\"false\"}[5m]))",
          "legendFormat": "Uncached"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "custom": { "drawStyle": "bars", "fillOpacity": 80, "lineWidth": 0, "stacking": { "mode": "normal" } }
        },
        "overrides": [
          {
            "matcher": { "id": "byName", "options": "Cached" },
            "properties": [{ "id": "color", "value": { "fixedColor": "green", "mode": "fixed" } }]
          },
          {
            "matcher": { "id": "byName", "options": "Uncached" },
            "properties": [{ "id": "color", "value": { "fixedColor": "blue", "mode": "fixed" } }]
          }
        ]
      }
    },
    {
      "title": "Request Rate (to gauge cache effectiveness)",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 24, "x": 0, "y": 28 },
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "llmhost_requests_per_minute",
          "legendFormat": "Requests/min"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "rpm",
          "custom": { "drawStyle": "line", "fillOpacity": 10, "lineWidth": 2 }
        },
        "overrides": []
      }
    }
  ],
  "schemaVersion": 39,
  "tags": ["llmhosts", "cache"],
  "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 Cache Performance",
  "uid": "llmhosts-cache",
  "version": 1
}
