refactor(server): prune otel dashboard and active http request

This commit is contained in:
RainbowBird
2026-03-30 20:10:50 +08:00
parent 33bf61f3f7
commit f31a37e7e4
6 changed files with 1540 additions and 2264 deletions
@@ -1,279 +0,0 @@
{
"annotations": { "list": [] },
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"panels": [
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
"id": 100,
"title": "Chat",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 50 },
{ "color": "red", "value": 200 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 1 },
"id": 1,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Chat Syncs (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(chat_sync_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "syncs"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 100 },
{ "color": "red", "value": 500 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 1 },
"id": 2,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Messages (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(chat_messages_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "messages"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "reqps"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 9 },
"id": 3,
"title": "Chat Sync Rate by Type",
"type": "timeseries",
"targets": [
{
"expr": "sum by (chat_type) (rate(chat_sync_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "{{chat_type}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 9 },
"id": 4,
"title": "Message Volume Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(rate(chat_messages_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "messages/s"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 17 },
"id": 101,
"title": "Characters",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 10 },
{ "color": "red", "value": 50 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 18 },
"id": 5,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Characters Created (24h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(character_created_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "created"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 5 },
{ "color": "red", "value": 20 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 18 },
"id": 6,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Characters Deleted (24h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(character_deleted_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "deleted"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "bars",
"fillOpacity": 80,
"stacking": { "mode": "normal" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 26 },
"id": 7,
"title": "Engagement Actions",
"type": "timeseries",
"targets": [
{
"expr": "sum by (action) (rate(character_engagement_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "{{action}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 26 },
"id": 8,
"title": "Character Creation Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(rate(character_created_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "created/s"
}
]
}
],
"schemaVersion": 39,
"tags": ["airi", "engagement", "grafana-cloud"],
"templating": {
"list": [
{
"current": { "selected": false, "text": "production", "value": "production" },
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"definition": "label_values(http_server_request_duration_milliseconds_count, deployment_environment)",
"hide": 0,
"includeAll": true,
"multi": false,
"name": "env",
"query": "label_values(http_server_request_duration_milliseconds_count, deployment_environment)",
"refresh": 2,
"type": "query"
},
{
"current": { "selected": false, "text": "server", "value": "server" },
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"definition": "label_values(http_server_request_duration_milliseconds_count{deployment_environment=~\"$env\"}, service_name)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "service",
"query": "label_values(http_server_request_duration_milliseconds_count{deployment_environment=~\"$env\"}, service_name)",
"refresh": 2,
"type": "query"
}
]
},
"time": { "from": "now-24h", "to": "now" },
"title": "AIRI Engagement (Cloud)",
"uid": "airi-engagement-cloud"
}
@@ -1,319 +0,0 @@
{
"annotations": { "list": [] },
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"panels": [
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
"id": 100,
"title": "Stripe",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 10 },
{ "color": "red", "value": 50 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 6, "x": 0, "y": 1 },
"id": 1,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Checkouts Created (24h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(stripe_checkout_created_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "created"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 5 },
{ "color": "red", "value": 30 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 6, "x": 6, "y": 1 },
"id": 2,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Checkouts Completed (24h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(stripe_checkout_completed_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "completed"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "red", "value": null },
{ "color": "yellow", "value": 1 },
{ "color": "red", "value": 5 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 6, "x": 12, "y": 1 },
"id": 3,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Payment Failures (24h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(stripe_payment_failed_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "failures"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "red", "value": null },
{ "color": "yellow", "value": 0.5 },
{ "color": "green", "value": 0.8 }
]
},
"unit": "percentunit"
}
},
"gridPos": { "h": 8, "w": 6, "x": 18, "y": 1 },
"id": 4,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Conversion Rate",
"type": "stat",
"targets": [
{
"expr": "sum(increase(stripe_checkout_completed_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h])) / sum(increase(stripe_checkout_created_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "conversion"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 9 },
"id": 5,
"title": "Checkout Funnel Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(rate(stripe_checkout_created_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "created/s"
},
{
"expr": "sum(rate(stripe_checkout_completed_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "completed/s"
},
{
"expr": "sum(rate(stripe_payment_failed_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "failed/s"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "bars",
"fillOpacity": 80,
"stacking": { "mode": "normal" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 9 },
"id": 6,
"title": "Subscription Events",
"type": "timeseries",
"targets": [
{
"expr": "sum by (event_type) (rate(stripe_subscription_event_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "{{event_type}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 17 },
"id": 7,
"title": "Stripe Events by Type",
"type": "timeseries",
"targets": [
{
"expr": "sum by (event_type) (rate(stripe_events_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "{{event_type}}"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 25 },
"id": 101,
"title": "Flux",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 5 },
{ "color": "red", "value": 20 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 26 },
"id": 8,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Insufficient Balance (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(flux_insufficient_balance_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "insufficient"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 16, "x": 8, "y": 26 },
"id": 9,
"title": "Insufficient Balance Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(rate(flux_insufficient_balance_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "insufficient/s"
}
]
}
],
"schemaVersion": 39,
"tags": ["airi", "revenue", "stripe", "grafana-cloud"],
"templating": {
"list": [
{
"current": { "selected": false, "text": "production", "value": "production" },
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"definition": "label_values(http_server_request_duration_milliseconds_count, deployment_environment)",
"hide": 0,
"includeAll": true,
"multi": false,
"name": "env",
"query": "label_values(http_server_request_duration_milliseconds_count, deployment_environment)",
"refresh": 2,
"type": "query"
},
{
"current": { "selected": false, "text": "server", "value": "server" },
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"definition": "label_values(http_server_request_duration_milliseconds_count{deployment_environment=~\"$env\"}, service_name)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "service",
"query": "label_values(http_server_request_duration_milliseconds_count{deployment_environment=~\"$env\"}, service_name)",
"refresh": 2,
"type": "query"
}
]
},
"time": { "from": "now-7d", "to": "now" },
"title": "AIRI Revenue (Cloud)",
"uid": "airi-revenue-cloud"
}
File diff suppressed because it is too large Load Diff
@@ -1,503 +0,0 @@
{
"annotations": {
"list": []
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"panels": [
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
"id": 100,
"title": "HTTP Overview",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 100 },
{ "color": "red", "value": 500 }
]
},
"unit": "reqps"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 1 },
"id": 1,
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"orientation": "auto",
"textMode": "auto",
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto"
},
"title": "Request Rate",
"type": "stat",
"targets": [
{
"expr": "sum(rate(airi_http_server_request_duration_seconds_count{service_name=~\"$service\"}[$__rate_interval]))",
"legendFormat": "req/s"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 0.01 },
{ "color": "red", "value": 0.05 }
]
},
"unit": "percentunit"
}
},
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 1 },
"id": 2,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Error Rate (5xx)",
"type": "stat",
"targets": [
{
"expr": "sum(rate(airi_http_server_request_duration_seconds_count{service_name=~\"$service\", http_status_code=~\"5..\"}[$__rate_interval])) / sum(rate(airi_http_server_request_duration_seconds_count{service_name=~\"$service\"}[$__rate_interval]))",
"legendFormat": "error rate"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 0.2 },
{ "color": "red", "value": 1.0 }
]
},
"unit": "s"
}
},
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 1 },
"id": 3,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "P95 Latency (excl. LLM)",
"type": "stat",
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(airi_http_server_request_duration_seconds_bucket{service_name=~\"$service\", http_route!~\"/api/v1/openai/.*\"}[$__rate_interval])) by (le))",
"legendFormat": "p95"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "reqps"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 9 },
"id": 4,
"title": "Request Rate by Route",
"type": "timeseries",
"targets": [
{
"expr": "sum by (http_route) (rate(airi_http_server_request_duration_seconds_count{service_name=~\"$service\"}[$__rate_interval]))",
"legendFormat": "{{http_route}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "s"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 9 },
"id": 5,
"title": "Latency by Route (P95)",
"type": "timeseries",
"targets": [
{
"expr": "histogram_quantile(0.95, sum by (le, http_route) (rate(airi_http_server_request_duration_seconds_bucket{service_name=~\"$service\"}[$__rate_interval])))",
"legendFormat": "{{http_route}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "bars",
"fillOpacity": 80,
"stacking": { "mode": "normal" }
},
"unit": "reqps"
}
},
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 17 },
"id": 6,
"title": "Response Status Codes",
"type": "timeseries",
"targets": [
{
"expr": "sum by (http_status_code) (rate(airi_http_server_request_duration_seconds_count{service_name=~\"$service\"}[$__rate_interval]))",
"legendFormat": "{{http_status_code}}"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 25 },
"id": 101,
"title": "Node.js Runtime",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "bytes"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 26 },
"id": 7,
"title": "Heap Memory Usage",
"type": "timeseries",
"targets": [
{
"expr": "airi_process_runtime_nodejs_memory_heap_total{service_name=~\"$service\"}",
"legendFormat": "heap total"
},
{
"expr": "airi_process_runtime_nodejs_memory_heap_used{service_name=~\"$service\"}",
"legendFormat": "heap used"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "bytes"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 26 },
"id": 8,
"title": "RSS & External Memory",
"type": "timeseries",
"targets": [
{
"expr": "airi_process_runtime_nodejs_memory_rss{service_name=~\"$service\"}",
"legendFormat": "RSS"
},
{
"expr": "airi_process_runtime_nodejs_memory_array_buffers{service_name=~\"$service\"}",
"legendFormat": "array buffers"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 34 },
"id": 9,
"title": "Event Loop Lag",
"type": "timeseries",
"targets": [
{
"expr": "airi_process_runtime_nodejs_event_loop_lag_p99{service_name=~\"$service\"}",
"legendFormat": "p99 lag"
},
{
"expr": "airi_process_runtime_nodejs_event_loop_lag_p50{service_name=~\"$service\"}",
"legendFormat": "p50 lag"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 34 },
"id": 10,
"title": "Active Handles & Requests",
"type": "timeseries",
"targets": [
{
"expr": "airi_process_runtime_nodejs_active_handles_total{service_name=~\"$service\"}",
"legendFormat": "active handles"
},
{
"expr": "airi_process_runtime_nodejs_active_requests_total{service_name=~\"$service\"}",
"legendFormat": "active requests"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 42 },
"id": 102,
"title": "PostgreSQL",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "s"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 43 },
"id": 11,
"title": "DB Query Duration (P95)",
"type": "timeseries",
"targets": [
{
"expr": "histogram_quantile(0.95, sum by (le, db_operation) (rate(airi_db_client_operation_duration_seconds_bucket{service_name=~\"$service\"}[$__rate_interval])))",
"legendFormat": "{{db_operation}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "ops"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 43 },
"id": 12,
"title": "DB Query Rate",
"type": "timeseries",
"targets": [
{
"expr": "sum by (db_operation) (rate(airi_db_client_operation_duration_seconds_count{service_name=~\"$service\"}[$__rate_interval]))",
"legendFormat": "{{db_operation}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 51 },
"id": 13,
"title": "DB Connection Pool",
"type": "timeseries",
"targets": [
{
"expr": "airi_db_client_connections_usage{service_name=~\"$service\", state=\"used\"}",
"legendFormat": "used"
},
{
"expr": "airi_db_client_connections_usage{service_name=~\"$service\", state=\"idle\"}",
"legendFormat": "idle"
},
{
"expr": "airi_db_client_connections_pending_requests{service_name=~\"$service\"}",
"legendFormat": "pending"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 59 },
"id": 103,
"title": "Redis",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "s"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 60 },
"id": 14,
"title": "Redis Command Duration (P95)",
"type": "timeseries",
"targets": [
{
"expr": "histogram_quantile(0.95, sum by (le, db_operation) (rate(airi_db_client_operation_duration_seconds_bucket{service_name=~\"$service\", db_system=\"redis\"}[$__rate_interval])))",
"legendFormat": "{{db_operation}}"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20
},
"unit": "ops"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 60 },
"id": 15,
"title": "Redis Command Rate",
"type": "timeseries",
"targets": [
{
"expr": "sum by (db_operation) (rate(airi_db_client_operation_duration_seconds_count{service_name=~\"$service\", db_system=\"redis\"}[$__rate_interval]))",
"legendFormat": "{{db_operation}}"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 68 },
"id": 104,
"title": "Application Logs",
"type": "row"
},
{
"datasource": { "type": "loki", "uid": "loki" },
"gridPos": { "h": 10, "w": 24, "x": 0, "y": 69 },
"id": 16,
"title": "Application Logs",
"type": "logs",
"targets": [
{
"expr": "{service_name=~\"$service\"} |= ``",
"legendFormat": ""
}
],
"options": {
"showTime": true,
"showLabels": true,
"showCommonLabels": false,
"wrapLogMessage": true,
"prettifyLogMessage": false,
"enableLogDetails": true,
"sortOrder": "Descending"
}
}
],
"schemaVersion": 39,
"tags": ["airi", "observability"],
"templating": {
"list": [
{
"current": { "selected": false, "text": "Prometheus", "value": "Prometheus" },
"hide": 0,
"includeAll": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"refresh": 1,
"type": "datasource"
},
{
"current": { "selected": false, "text": "airi-server", "value": "airi-server" },
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"definition": "label_values(airi_http_server_request_duration_seconds_count, service_name)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "service",
"query": "label_values(airi_http_server_request_duration_seconds_count, service_name)",
"refresh": 2,
"type": "query"
}
]
},
"time": { "from": "now-1h", "to": "now" },
"title": "AIRI Server Overview",
"uid": "airi-server-overview"
}
@@ -1,421 +0,0 @@
{
"annotations": { "list": [] },
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"panels": [
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
"id": 100,
"title": "Registration",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 10 },
{ "color": "red", "value": 50 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 1 },
"id": 1,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"orientation": "auto",
"textMode": "auto",
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto"
},
"title": "New Users (24h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(user_registered_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[24h]))",
"legendFormat": "new users"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 5 },
{ "color": "red", "value": 20 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 1 },
"id": 2,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "New Users (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(user_registered_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "new users"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 0.1 },
{ "color": "red", "value": 1 }
]
},
"unit": "reqps"
}
},
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 1 },
"id": 3,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Registration Rate",
"type": "stat",
"targets": [
{
"expr": "sum(rate(user_registered_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "reg/s"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "bars",
"fillOpacity": 80,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 9 },
"id": 4,
"title": "Registrations Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(increase(user_registered_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "new users"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 17 },
"id": 101,
"title": "Sessions",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 50 },
{ "color": "red", "value": 200 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 18 },
"id": 5,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Active Sessions",
"type": "stat",
"targets": [
{
"expr": "sum(user_active_sessions{service_name=~\"$service\", deployment_environment=~\"$env\"})",
"legendFormat": "active"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 50 },
{ "color": "red", "value": 200 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 18 },
"id": 6,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Logins (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(user_login_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "logins"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 26 },
"id": 7,
"title": "Login Rate Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(rate(user_login_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "logins/s"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 26 },
"id": 8,
"title": "Active Sessions Over Time",
"type": "timeseries",
"targets": [
{
"expr": "sum(user_active_sessions{service_name=~\"$service\", deployment_environment=~\"$env\"})",
"legendFormat": "active sessions"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 34 },
"id": 102,
"title": "Auth Health",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 100 },
{ "color": "red", "value": 500 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 35 },
"id": 9,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Auth Attempts (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(auth_attempts_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "attempts"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 5 },
{ "color": "red", "value": 20 }
]
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 35 },
"id": 10,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Auth Failures (1h)",
"type": "stat",
"targets": [
{
"expr": "sum(increase(auth_failures_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[1h]))",
"legendFormat": "failures"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 0.05 },
{ "color": "red", "value": 0.2 }
]
},
"unit": "percentunit"
}
},
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 35 },
"id": 11,
"options": {
"reduceOptions": { "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area"
},
"title": "Auth Failure Rate",
"type": "stat",
"targets": [
{
"expr": "sum(rate(auth_failures_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval])) / sum(rate(auth_attempts_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "failure rate"
}
]
},
{
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"stacking": { "mode": "none" }
},
"unit": "short"
}
},
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 43 },
"id": 12,
"title": "Auth Trends",
"type": "timeseries",
"targets": [
{
"expr": "sum(rate(auth_attempts_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "attempts/s"
},
{
"expr": "sum(rate(auth_failures_total{service_name=~\"$service\", deployment_environment=~\"$env\"}[$__rate_interval]))",
"legendFormat": "failures/s"
}
]
}
],
"schemaVersion": 39,
"tags": ["airi", "users", "auth", "grafana-cloud"],
"templating": {
"list": [
{
"current": { "selected": false, "text": "production", "value": "production" },
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"definition": "label_values(http_server_request_duration_milliseconds_count, deployment_environment)",
"hide": 0,
"includeAll": true,
"multi": false,
"name": "env",
"query": "label_values(http_server_request_duration_milliseconds_count, deployment_environment)",
"refresh": 2,
"type": "query"
},
{
"current": { "selected": false, "text": "server", "value": "server" },
"datasource": { "type": "prometheus", "uid": "grafanacloud-projairi-prom" },
"definition": "label_values(http_server_request_duration_milliseconds_count{deployment_environment=~\"$env\"}, service_name)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "service",
"query": "label_values(http_server_request_duration_milliseconds_count{deployment_environment=~\"$env\"}, service_name)",
"refresh": 2,
"type": "query"
}
]
},
"time": { "from": "now-24h", "to": "now" },
"title": "AIRI User & Auth (Cloud)",
"uid": "airi-user-auth-cloud"
}
+6 -8
View File
@@ -11,11 +11,15 @@ const tracer = trace.getTracer('airi-server-hono')
/**
* Hono middleware that creates spans for each request and records
* custom HTTP metrics (duration, active requests, status codes).
* active request counts.
*
* NOTICE: Request duration is intentionally NOT recorded here. The
* Node HTTP instrumentation already emits `http.server.request.duration`,
* and recording the same metric here would double-count every request in
* Grafana panels that read the histogram `_count` series as request rate.
*/
export function otelMiddleware(http: HttpMetrics): MiddlewareHandler<HonoEnv> {
return async (c, next) => {
const startTime = performance.now()
const method = c.req.method
const path = c.req.path
@@ -38,12 +42,6 @@ export function otelMiddleware(http: HttpMetrics): MiddlewareHandler<HonoEnv> {
if (status >= 500) {
span.setStatus({ code: SpanStatusCode.ERROR, message: `HTTP ${status}` })
}
http.requestDuration.record((performance.now() - startTime) / 1000, {
'http.request.method': method,
'http.route': path,
'http.response.status_code': status,
})
}
catch (err) {
const errorMessage = errorMessageFromUnknown(err)