Files
test_loki/docker/grafana/dashboards/ai-api-token-analysis.json
2025-10-28 01:43:28 +08:00

74 lines
1.8 KiB
JSON

{
"title": "AI API Token Analysis",
"panels": [
{
"title": "Top 10 Most Used Tokens (last 5m)",
"type": "barchart",
"datasource": "Loki",
"targets": [
{
"expr": "{job=\"ai-api\"} | logfmt | topk(10, count_over_time(5m)) by (token)",
"legendFormat": "{{token}}",
"refId": "A"
}
],
"gridPos": { "x": 0, "y": 0, "w": 12, "h": 8 }
},
{
"title": "Requests per Second by Token (last 1m)",
"type": "graph",
"datasource": "Loki",
"targets": [
{
"expr": "sum by (token) (rate({job=\"ai-api\"}[1m]))",
"legendFormat": "{{token}}",
"refId": "A"
}
],
"gridPos": { "x": 12, "y": 0, "w": 12, "h": 8 }
},
{
"title": "Error Rate (HTTP 4xx/5xx)",
"type": "stat",
"datasource": "Loki",
"targets": [
{
"expr": "sum by (job) (rate({job=\"ai-api\", response_code=~\"[45]..\"}[5m]))",
"legendFormat": "Error Rate",
"refId": "A"
}
],
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"values": false
}
},
"gridPos": { "x": 0, "y": 8, "w": 6, "h": 4 }
},
{
"title": "Avg Latency by Token",
"type": "timeseries",
"datasource": "Loki",
"targets": [
{
"expr": "{job=\"ai-api\"} | logfmt | avg(latency_ms) by (token)",
"legendFormat": "{{token}}",
"refId": "A"
}
],
"gridPos": { "x": 6, "y": 8, "w": 18, "h": 8 }
}
],
"refresh": "5s",
"time": {
"from": "now-1h",
"to": "now"
},
"timezone": "browser",
"panels": [],
"schemaVersion": 26,
"version": 1,
"editable": true,
"uid": "ai-api-token-analysis"
}