{ "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "enable": true, "expr": "changes(kube_deployment_status_observed_generation{namespace=~\"$namespace\", deployment=~\"agent-monitor.*\"}[2m]) > 0", "iconColor": "#6ED0E0", "name": "Deployments", "titleFormat": "Deployment updated" } ] }, "description": "Comprehensive monitoring dashboard for Claude Code Agent Monitor", "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, "id": null, "links": [], "panels": [ { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 100, "title": "Overview", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "mappings": [ { "options": { "0": { "color": "red", "text": "DOWN" }, "1": { "color": "green", "text": "UP" } }, "type": "value" } ], "thresholds": { "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 1 } ] } } }, "gridPos": { "h": 4, "w": 4, "x": 0, "y": 1 }, "id": 1, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "textMode": "value", "reduceOptions": { "calcs": ["lastNotNull"] } }, "title": "Uptime Status", "type": "stat", "targets": [ { "expr": "up{job=\"agent-monitor\", namespace=~\"$namespace\"}", "legendFormat": "{{instance}}", "refId": "A" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "unit": "dtdurations", "thresholds": { "steps": [{ "color": "green", "value": null }] } } }, "gridPos": { "h": 4, "w": 4, "x": 4, "y": 1 }, "id": 2, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "center", "textMode": "value", "reduceOptions": { "calcs": ["lastNotNull"] } }, "title": "Uptime Duration", "type": "stat", "targets": [ { "expr": "time() - process_start_time_seconds{job=\"agent-monitor\", namespace=~\"$namespace\"}", "legendFormat": "", "refId": "A" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "unit": "short", "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 2 }, { "color": "red", "value": 0 } ] } } }, "gridPos": { "h": 4, "w": 4, "x": 8, "y": 1 }, "id": 3, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "textMode": "value", "reduceOptions": { "calcs": ["lastNotNull"] } }, "title": "Pod Count", "type": "stat", "targets": [ { "expr": "count(kube_pod_status_ready{namespace=~\"$namespace\", condition=\"true\"} == 1)", "legendFormat": "Ready", "refId": "A" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "unit": "short", "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 1 }, { "color": "red", "value": 3 } ] } } }, "gridPos": { "h": 4, "w": 4, "x": 12, "y": 1 }, "id": 4, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "textMode": "value", "reduceOptions": { "calcs": ["lastNotNull"] } }, "title": "Pod Restarts (1h)", "type": "stat", "targets": [ { "expr": "sum(increase(kube_pod_container_status_restarts_total{namespace=~\"$namespace\", container=\"agent-monitor\"}[1h]))", "legendFormat": "", "refId": "A" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "unit": "short", "thresholds": { "steps": [{ "color": "blue", "value": null }] } } }, "gridPos": { "h": 4, "w": 4, "x": 16, "y": 1 }, "id": 5, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "textMode": "value", "reduceOptions": { "calcs": ["lastNotNull"] } }, "title": "Active WebSocket Connections", "type": "stat", "targets": [ { "expr": "sum(websocket_connections_active{job=\"agent-monitor\", namespace=~\"$namespace\"})", "legendFormat": "", "refId": "A" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "unit": "decbytes", "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 5368709120 }, { "color": "red", "value": 8589934592 } ] } } }, "gridPos": { "h": 4, "w": 4, "x": 20, "y": 1 }, "id": 6, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "textMode": "value", "reduceOptions": { "calcs": ["lastNotNull"] } }, "title": "SQLite DB Size", "type": "stat", "targets": [ { "expr": "kubelet_volume_stats_used_bytes{namespace=~\"$namespace\", persistentvolumeclaim=~\"agent-monitor.*\"}", "legendFormat": "", "refId": "A" } ] }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 5 }, "id": 101, "title": "HTTP Traffic", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisLabel": "req/s", "drawStyle": "line", "fillOpacity": 15, "lineWidth": 2, "pointSize": 5, "spanNulls": false, "stacking": { "mode": "none" } }, "unit": "reqps" }, "overrides": [ { "matcher": { "id": "byRegexp", "options": "5.." }, "properties": [{ "id": "color", "value": { "fixedColor": "red", "mode": "fixed" } }] }, { "matcher": { "id": "byRegexp", "options": "4.." }, "properties": [{ "id": "color", "value": { "fixedColor": "yellow", "mode": "fixed" } }] }, { "matcher": { "id": "byRegexp", "options": "2.." }, "properties": [{ "id": "color", "value": { "fixedColor": "green", "mode": "fixed" } }] } ] }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 6 }, "id": 10, "options": { "legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi", "sort": "desc" } }, "title": "Request Rate (RPS)", "type": "timeseries", "targets": [ { "expr": "sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m])) by (status)", "legendFormat": "{{ status }}", "refId": "A" }, { "expr": "sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m]))", "legendFormat": "Total", "refId": "B" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisLabel": "%", "drawStyle": "line", "fillOpacity": 20, "lineWidth": 2, "thresholdsStyle": { "mode": "line" } }, "max": 100, "min": 0, "unit": "percent", "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 2 }, { "color": "red", "value": 5 } ] } } }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 6 }, "id": 11, "options": { "legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "Error Rate (%)", "type": "timeseries", "targets": [ { "expr": "100 * sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\", status=~\"5..\"}[5m])) / sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m]))", "legendFormat": "5xx Error Rate", "refId": "A" }, { "expr": "100 * sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\", status=~\"4..\"}[5m])) / sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m]))", "legendFormat": "4xx Error Rate", "refId": "B" } ] }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 14 }, "id": 102, "title": "Latency", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisLabel": "seconds", "drawStyle": "line", "fillOpacity": 10, "lineWidth": 2, "spanNulls": false }, "unit": "s", "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 0.5 }, { "color": "red", "value": 1 } ] } } }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 15 }, "id": 20, "options": { "legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi", "sort": "desc" } }, "title": "Response Latency (p50 / p90 / p99)", "type": "timeseries", "targets": [ { "expr": "histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m])) by (le))", "legendFormat": "p50", "refId": "A" }, { "expr": "histogram_quantile(0.90, sum(rate(http_request_duration_seconds_bucket{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m])) by (le))", "legendFormat": "p90", "refId": "B" }, { "expr": "histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m])) by (le))", "legendFormat": "p99", "refId": "C" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "drawStyle": "bars", "fillOpacity": 80, "lineWidth": 1, "stacking": { "mode": "normal" } }, "unit": "reqps" } }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 15 }, "id": 21, "options": { "legend": { "calcs": ["mean"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "Request Rate by Endpoint", "type": "timeseries", "targets": [ { "expr": "sum(rate(http_requests_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m])) by (handler)", "legendFormat": "{{ handler }}", "refId": "A" } ] }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 23 }, "id": 103, "title": "WebSocket & Connections", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "drawStyle": "line", "fillOpacity": 25, "lineWidth": 2, "spanNulls": false }, "unit": "short" } }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 24 }, "id": 30, "options": { "legend": { "calcs": ["mean", "max", "last"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "Active WebSocket Connections", "type": "timeseries", "targets": [ { "expr": "websocket_connections_active{job=\"agent-monitor\", namespace=~\"$namespace\"}", "legendFormat": "{{ pod }}", "refId": "A" }, { "expr": "sum(websocket_connections_active{job=\"agent-monitor\", namespace=~\"$namespace\"})", "legendFormat": "Total", "refId": "B" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "drawStyle": "line", "fillOpacity": 10, "lineWidth": 2 }, "unit": "short" } }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 24 }, "id": 31, "options": { "legend": { "calcs": ["sum"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "WebSocket Messages (rate/s)", "type": "timeseries", "targets": [ { "expr": "sum(rate(websocket_messages_sent_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m]))", "legendFormat": "Sent", "refId": "A" }, { "expr": "sum(rate(websocket_messages_received_total{job=\"agent-monitor\", namespace=~\"$namespace\"}[5m]))", "legendFormat": "Received", "refId": "B" } ] }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 32 }, "id": 104, "title": "Resource Usage", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "drawStyle": "line", "fillOpacity": 20, "lineWidth": 2, "thresholdsStyle": { "mode": "line+area" } }, "unit": "bytes", "thresholds": { "steps": [ { "color": "transparent", "value": null }, { "color": "red", "value": 536870912 } ] } } }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 33 }, "id": 40, "options": { "legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "Memory Usage", "type": "timeseries", "targets": [ { "expr": "container_memory_working_set_bytes{namespace=~\"$namespace\", container=\"agent-monitor\"}", "legendFormat": "{{ pod }} (working set)", "refId": "A" }, { "expr": "container_spec_memory_limit_bytes{namespace=~\"$namespace\", container=\"agent-monitor\"}", "legendFormat": "{{ pod }} (limit)", "refId": "B" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "drawStyle": "line", "fillOpacity": 20, "lineWidth": 2, "thresholdsStyle": { "mode": "line" } }, "unit": "percentunit", "max": 1, "min": 0, "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 0.7 }, { "color": "red", "value": 0.9 } ] } } }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 33 }, "id": 41, "options": { "legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "CPU Usage", "type": "timeseries", "targets": [ { "expr": "rate(container_cpu_usage_seconds_total{namespace=~\"$namespace\", container=\"agent-monitor\"}[5m])", "legendFormat": "{{ pod }}", "refId": "A" } ] }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 41 }, "id": 105, "title": "Storage", "type": "row" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "drawStyle": "line", "fillOpacity": 20, "lineWidth": 2, "thresholdsStyle": { "mode": "line+area" } }, "unit": "decbytes", "thresholds": { "steps": [ { "color": "transparent", "value": null }, { "color": "yellow", "value": 8589934592 }, { "color": "red", "value": 9663676416 } ] } } }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 42 }, "id": 50, "options": { "legend": { "calcs": ["last", "max"], "displayMode": "table", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "title": "SQLite DB Size (PV Usage)", "type": "timeseries", "targets": [ { "expr": "kubelet_volume_stats_used_bytes{namespace=~\"$namespace\", persistentvolumeclaim=~\"agent-monitor.*\"}", "legendFormat": "Used ({{ persistentvolumeclaim }})", "refId": "A" }, { "expr": "kubelet_volume_stats_capacity_bytes{namespace=~\"$namespace\", persistentvolumeclaim=~\"agent-monitor.*\"}", "legendFormat": "Capacity ({{ persistentvolumeclaim }})", "refId": "B" } ] }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "max": 100, "min": 0, "unit": "percent", "thresholds": { "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 75 }, { "color": "red", "value": 90 } ] } } }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 42 }, "id": 51, "options": { "orientation": "horizontal", "reduceOptions": { "calcs": ["lastNotNull"] }, "showThresholdLabels": false, "showThresholdMarkers": true }, "title": "PV Usage (%)", "type": "gauge", "targets": [ { "expr": "100 * kubelet_volume_stats_used_bytes{namespace=~\"$namespace\", persistentvolumeclaim=~\"agent-monitor.*\"} / kubelet_volume_stats_capacity_bytes{namespace=~\"$namespace\", persistentvolumeclaim=~\"agent-monitor.*\"}", "legendFormat": "{{ persistentvolumeclaim }}", "refId": "A" } ] } ], "refresh": "30s", "schemaVersion": 39, "tags": ["agent-monitor", "nodejs", "websocket"], "templating": { "list": [ { "current": { "selected": false, "text": "Prometheus", "value": "prometheus" }, "hide": 0, "includeAll": false, "label": "Data Source", "name": "datasource", "options": [], "query": "prometheus", "type": "datasource" }, { "current": {}, "datasource": { "type": "prometheus", "uid": "${datasource}" }, "definition": "label_values(up{job=\"agent-monitor\"}, namespace)", "hide": 0, "includeAll": true, "label": "Namespace", "multi": false, "name": "namespace", "query": { "qryType": 1, "query": "label_values(up{job=\"agent-monitor\"}, namespace)" }, "refresh": 2, "type": "query" } ] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": { "refresh_intervals": ["10s", "30s", "1m", "5m", "15m"], "time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"] }, "timezone": "browser", "title": "Claude Code Agent Monitor", "uid": "agent-monitor-main", "version": 1 }