monitoring: llama-swap GPU/LLM stack (v250) — PrometheusRule, Grafana dashboard, scrape config, VRAM exporter

This commit is contained in:
Hermes Agent service account
2026-08-18 22:22:53 -05:00
parent 03b3ce9dee
commit 7867be688a
17 changed files with 2951 additions and 27 deletions

View File

@@ -0,0 +1,73 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: llama-swap-alerts
namespace: monitoring
labels:
prometheus: kube-prometheus
app.kubernetes.io/part-of: monitoring
spec:
groups:
- name: llama-swap.rules
interval: 30s
rules:
# ====================================================================
# CRITICAL: GPU VRAM saturation (OOM risk)
# ====================================================================
- alert: LlamaSwapVramSaturation
expr: llamacpp_vram_used_mib > 24000
for: 1m
labels:
severity: critical
component: llm-inference
annotations:
summary: "GPU VRAM saturation on {{ $labels.instance }}"
description: |
GPU VRAM usage is {{ $value | humanize }}MiB (critical threshold: 24000MiB).
The system is at risk of out-of-memory (OOM) kernel-kill events.
# ====================================================================
# WARNING: KV-cache spill risk (context cache pressure)
# ====================================================================
- alert: LlamaSwapKvCacheSpill
expr: llamacpp_kv_cache_usage_ratio > 0.92
for: 2m
labels:
severity: warning
component: llm-inference
annotations:
summary: "KV-cache spill risk on model {{ $labels.model }}"
description: |
KV-cache utilization on {{ $labels.model }} is {{ $value | humanizePercentage }}
(warning threshold: 92%).
# ====================================================================
# WARNING: Throughput degradation (possible throttling)
# ====================================================================
- alert: LlamaSwapThroughputDegradation
expr: |
(rate(llamacpp_tokens_predicted_total[5m]) * 60) < 40
for: 5m
labels:
severity: warning
component: llm-inference
annotations:
summary: "Token generation throughput low on {{ $labels.model }}"
description: |
Token generation rate is {{ $value | humanize }} tokens/min on {{ $labels.model }}
(baseline threshold: ~50+ tokens/min).
# ====================================================================
# WARNING: Scrape failures (monitoring health)
# ====================================================================
- alert: LlamaSwapScrapeFailed
expr: up{job="llama-swap"} == 0
for: 2m
labels:
severity: warning
component: monitoring
annotations:
summary: "llama-swap Prometheus scrape failed"
description: |
Prometheus cannot scrape llama-swap's /metrics endpoint.
Check: systemctl status llama-swap, curl http://{{ $labels.instance }}/metrics

View File

@@ -0,0 +1,556 @@
---
# ------------------------------------------------------------------------------
# FILE: cluster/applications/monitoring/llama-swap-dashboard.yaml
# DESCRIPTION: Custom Grafana dashboard for llama-swap GPU/LLM monitoring.
# Picked up automatically by the Grafana sidecar via label:
# grafana_dashboard: "1"
# Based on the Ciro Luciotta homelab LLM monitoring pattern.
#
# USAGE: This ConfigMap is reconciled by ArgoCD. The dashboard JSON is
# embedded inline (data key ends in .json).
# ------------------------------------------------------------------------------
apiVersion: v1
kind: ConfigMap
metadata:
name: dashboard-llama-swap
namespace: monitoring
labels:
grafana_dashboard: "1"
app.kubernetes.io/part-of: monitoring
data:
llama-swap.json: |
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"links": [],
"panels": [
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "MiB",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"max": 24576,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 23000
},
{
"color": "red",
"value": 24000
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [
"last",
"max"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.0.0",
"targets": [
{
"expr": "llamacpp_vram_used_mib{job=\"node\"}",
"interval": "",
"legendFormat": "VRAM Used",
"refId": "A"
}
],
"title": "GPU VRAM Usage",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"max": 1,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 0.8
},
{
"color": "orange",
"value": 0.92
},
{
"color": "red",
"value": 0.95
}
]
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"orientation": "auto",
"reduceOptions": {
"values": false,
"fields": "",
"calcs": [
"lastNotNull"
]
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "8.0.0",
"targets": [
{
"expr": "llamacpp_kv_cache_usage_ratio",
"interval": "",
"legendFormat": "{{ model }}",
"refId": "A"
}
],
"title": "KV-Cache Utilization (Gauge)",
"type": "gauge"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "ms/token",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.0.0",
"targets": [
{
"expr": "rate(llamacpp_time_predict_ms_sum[5m]) / rate(llamacpp_time_predict_ms_count[5m])",
"interval": "",
"legendFormat": "{{ model }}",
"refId": "A"
}
],
"title": "Prediction Latency by Model",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "Queue Size",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 3
},
{
"color": "red",
"value": 5
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.0.0",
"targets": [
{
"expr": "llamacpp_queue_size",
"interval": "",
"legendFormat": "{{ model }}",
"refId": "A"
}
],
"title": "Request Queue Depth",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "tokens/min",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"calcs": [
"mean"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.0.0",
"targets": [
{
"expr": "rate(llamacpp_tokens_predicted_total[1m]) * 60",
"interval": "",
"legendFormat": "{{ model }} (tokens/min)",
"refId": "A"
}
],
"title": "Token Generation Throughput",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "Tokens",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 100,
"gradientMode": "none",
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.0.0",
"targets": [
{
"expr": "histogram_quantile(0.95, rate(llamacpp_time_predict_ms_bucket[5m]))",
"interval": "",
"legendFormat": "p95 latency",
"refId": "A"
},
{
"expr": "histogram_quantile(0.99, rate(llamacpp_time_predict_ms_bucket[5m]))",
"interval": "",
"legendFormat": "p99 latency",
"refId": "B"
}
],
"title": "Latency Percentiles (p95, p99)",
"type": "timeseries"
}
],
"refresh": "30s",
"schemaVersion": 27,
"style": "dark",
"tags": [
"llm",
"llama-swap",
"gpu-monitoring",
"ciro-luciotta"
],
"templating": {
"list": []
},
"time": {
"from": "now-24h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "llama-swap GPU/LLM Monitoring",
"uid": "llama-swap-monitor",
"version": 1
}

View File

@@ -125,7 +125,7 @@ prometheus:
- target_label: __address__
replacement: snmp-exporter.monitoring.svc.cluster.local:9116
# usw-pro-aggregation
# SNMP usw-pro-aggregation
- job_name: snmp-usw-pro-aggregation
scrape_interval: 60s
scrape_timeout: 55s
@@ -266,31 +266,56 @@ prometheus:
# endpoint: astro-orbiter-router
# model: Qwen3.6-35B-A3B-UD-Q4_K_S
- job_name: llama-server-astro-orbiter-llama3
scrape_interval: 90s
metrics_path: /metrics
params:
model: ["Meta-Llama-3.1-8B-Instruct-Q4_K_M"]
static_configs:
- targets:
- 10.1.71.130:8002
labels:
hostname: astro-orbiter
endpoint: astro-orbiter-router
model: Meta-Llama-3.1-8B-Instruct-Q4_K_M
# llama-server-astro-orbiter-llama3 — DEPRECATED (2026-08-18):
# Router mode on :8002 replaced by llama-swap on :8001. llama-swap exposes
# single /metrics endpoint (not per-model). See llama-swap job below.
# - job_name: llama-server-astro-orbiter-llama3
# scrape_interval: 90s
# metrics_path: /metrics
# params:
# model: ["Meta-Llama-3.1-8B-Instruct-Q4_K_M"]
# static_configs:
# - targets:
# - 10.1.71.130:8002
# labels:
# hostname: astro-orbiter
# endpoint: astro-orbiter-router
# model: Meta-Llama-3.1-8B-Instruct-Q4_K_M
- job_name: llama-server-astro-orbiter-phi35
scrape_interval: 90s
metrics_path: /metrics
params:
model: ["Phi-3.5-mini-instruct-Q8_0"]
# llama-server-astro-orbiter-phi35 — DEPRECATED (2026-08-18):
# Same as above — router replaced by llama-swap. Use llama-swap /metrics.
# - job_name: llama-server-astro-orbiter-phi35
# scrape_interval: 90s
# metrics_path: /metrics
# params:
# model: ["Phi-3.5-mini-instruct-Q8_0"]
# static_configs:
# - targets:
# - 10.1.71.130:8002
# labels:
# hostname: astro-orbiter
# endpoint: astro-orbiter-router
# model: Phi-3.5-mini-instruct-Q8_0
# llama-swap (production, since 2026-08-18)
# Replaces the per-model /metrics?model=<id> jobs above (all targeting now-deprecated :8002).
# llama-swap natively exposes /metrics on its own endpoint with model-labeled metrics.
- job_name: llama-swap
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
- 10.1.71.130:8002
- 10.1.71.130:8001
labels:
hostname: astro-orbiter
endpoint: astro-orbiter-router
model: Phi-3.5-mini-instruct-Q8_0
service: llama-swap
environment: homelab
metrics_path: /metrics
honor_labels: true
metric_relabel_configs:
- source_labels: [__name__]
regex: 'llamacpp_.*'
action: keep
# ─── Grafana ──────────────────────────────────────────────────────────────────
grafana: