This commit is contained in:
2025-10-28 01:43:28 +08:00
commit 058c578ee6
8 changed files with 263 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
{
"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"
}

View File

@@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards

View File

@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- name: Loki
type: loki
url: http://loki:3100
access: proxy
isDefault: true
version: 1
editable: false