| title | Metrics Reference |
|---|
Complete reference for Prometheus metrics exposed by SMG. Metrics are organized in six layers matching the request lifecycle.
Metrics are exposed on the Prometheus port (default: 29000):
curl http://localhost:29000/metricsConfigure via CLI:
smg --prometheus-port 29000 --prometheus-host 0.0.0.0Metrics for incoming HTTP requests at the gateway edge.
Total HTTP requests received by the gateway.
| Type | Labels |
|---|---|
| Counter | method, path |
# Request rate by endpoint
sum by (path) (rate(smg_http_requests_total[5m]))
# Total request rate
sum(rate(smg_http_requests_total[5m]))
HTTP request duration from receipt to response.
| Type | Labels |
|---|---|
| Histogram | method, path |
# P99 latency by endpoint
histogram_quantile(0.99, sum by (path, le) (rate(smg_http_request_duration_seconds_bucket[5m])))
# Average latency
rate(smg_http_request_duration_seconds_sum[5m]) / rate(smg_http_request_duration_seconds_count[5m])
HTTP responses by path, status, and error code.
| Type | Labels |
|---|---|
| Counter | path, status_code, error_code |
# Error rate (5xx responses)
sum(rate(smg_http_responses_total{status_code=~"5.."}[5m])) / sum(rate(smg_http_responses_total[5m]))
# Success rate
sum(rate(smg_http_responses_total{status_code="200"}[5m])) / sum(rate(smg_http_responses_total[5m]))
# Success rate for /v1/responses
sum(rate(smg_http_responses_total{path="/v1/responses",status_code=~"2.."}[5m]))
/
sum(rate(smg_http_responses_total{path="/v1/responses"}[5m]))
Currently active HTTP connections.
| Type | Labels |
|---|---|
| Gauge | None |
Distribution of in-flight request ages for Grafana heatmaps.
| Type | Labels |
|---|---|
| Gauge | gt, le |
Age buckets (seconds): 30, 60, 180, 300, 600, 1200, 3600, 7200, 14400, 28800, 86400
Rate limiting decisions.
| Type | Labels |
|---|---|
| Counter | result |
Values: allowed, rejected
# Rejection rate
rate(smg_http_rate_limit_total{result="rejected"}[5m]) / sum(rate(smg_http_rate_limit_total[5m]))
Metrics for request routing and processing.
Requests processed by the router.
| Type | Labels |
|---|---|
| Counter | router_type, backend_type, connection_mode, model, endpoint, streaming |
Router types: openai, http, grpc
Backend types: regular, pd, external, harmony
Endpoints: chat, generate, responses, completions, rerank, embeddings, classify, messages, realtime, realtime_sessions, realtime_client_secrets, realtime_transcription
Streaming: true, false
# Request rate by model
sum by (model) (rate(smg_router_requests_total[5m]))
# Streaming vs non-streaming
sum by (streaming) (rate(smg_router_requests_total[5m]))
Total router request duration.
| Type | Labels |
|---|---|
| Histogram | router_type, backend_type, connection_mode, model, endpoint |
Router errors by type.
| Type | Labels |
|---|---|
| Counter | router_type, backend_type, connection_mode, model, endpoint, error_type |
Error types: no_workers, timeout, backend_error, validation_error, internal_error
# Error rate by type
sum by (error_type) (rate(smg_router_request_errors_total[5m]))
Duration of individual pipeline stages (gRPC mode only).
| Type | Labels |
|---|---|
| Histogram | router_type, stage |
Stage names are emitted by the gRPC pipeline (e.g., tokenize, route, inference, detokenize, tool_parse).
# Tokenization latency
histogram_quantile(0.99, rate(smg_router_stage_duration_seconds_bucket{stage="tokenize"}[5m]))
Time to first token (gRPC streaming only).
| Type | Labels |
|---|---|
| Histogram | router_type, backend_type, model, endpoint |
# P50 TTFT by model
histogram_quantile(0.5, sum by (model, le) (rate(smg_router_ttft_seconds_bucket[5m])))
Time per output token (gRPC streaming only).
| Type | Labels |
|---|---|
| Histogram | router_type, backend_type, model, endpoint |
# Average TPOT
rate(smg_router_tpot_seconds_sum[5m]) / rate(smg_router_tpot_seconds_count[5m])
Token counts by type.
| Type | Labels |
|---|---|
| Counter | router_type, backend_type, model, endpoint, token_type |
Token types: input, output
# Tokens per second
sum by (token_type) (rate(smg_router_tokens_total[5m]))
# Input/output ratio
sum(rate(smg_router_tokens_total{token_type="output"}[5m])) / sum(rate(smg_router_tokens_total{token_type="input"}[5m]))
Total generation time (first token to last token).
| Type | Labels |
|---|---|
| Histogram | router_type, backend_type, model, endpoint |
HTTP responses from upstream workers.
| Type | Labels |
|---|---|
| Counter | router_type, status_code, error_code |
Metrics for worker pool management and resilience.
Number of workers in the pool.
| Type | Labels |
|---|---|
| Gauge | worker_type, connection_mode, model |
Active connections per worker pool.
| Type | Labels |
|---|---|
| Gauge | worker_type, connection_mode |
Active requests per worker.
| Type | Labels |
|---|---|
| Gauge | worker |
# Load distribution across workers
smg_worker_requests_active / ignoring(worker) group_left sum(smg_worker_requests_active)
Worker health status.
| Type | Labels | Values |
|---|---|---|
| Gauge | worker |
1 = healthy, 0 = unhealthy |
# Count healthy workers
sum(smg_worker_health)
# Alert on unhealthy workers
smg_worker_health == 0
Health check results.
| Type | Labels |
|---|---|
| Counter | worker_type, result |
Results: success, failure
Worker selection events by load balancer.
| Type | Labels |
|---|---|
| Counter | worker_type, connection_mode, model, policy |
Worker-level errors by type.
| Type | Labels |
|---|---|
| Counter | worker_type, connection_mode, error_type |
Circuit breaker state per worker.
| Type | Labels | Values |
|---|---|---|
| Gauge | worker |
0 = closed, 1 = open, 2 = half-open |
# Workers with open circuits
count(smg_worker_cb_state == 1)
Circuit breaker state transitions.
| Type | Labels |
|---|---|
| Counter | worker, from, to |
Request outcomes tracked by circuit breaker.
| Type | Labels |
|---|---|
| Counter | worker, outcome |
Outcomes: success, failure
Consecutive failures per worker.
| Type | Labels |
|---|---|
| Gauge | worker |
Consecutive successes per worker.
| Type | Labels |
|---|---|
| Gauge | worker |
Retry attempts.
| Type | Labels |
|---|---|
| Counter | worker_type, endpoint |
Requests that exhausted all retries.
| Type | Labels |
|---|---|
| Counter | worker_type, endpoint |
Retry backoff durations by attempt number.
| Type | Labels |
|---|---|
| Histogram | attempt |
Metrics for service discovery.
Worker registrations.
| Type | Labels |
|---|---|
| Counter | source, result |
Sources: static, kubernetes, consul, manual
Worker deregistrations.
| Type | Labels |
|---|---|
| Counter | source, reason |
Discovery sync duration.
| Type | Labels |
|---|---|
| Histogram | source |
Workers discovered per source.
| Type | Labels |
|---|---|
| Gauge | source |
Metrics for Model Context Protocol tool execution.
MCP tool invocations.
| Type | Labels |
|---|---|
| Counter | model, tool_name, result |
Results: success, error
# Tool success rate
sum(rate(smg_mcp_tool_calls_total{result="success"}[5m])) / sum(rate(smg_mcp_tool_calls_total[5m]))
# Most used tools
topk(10, sum by (tool_name) (rate(smg_mcp_tool_calls_total[5m])))
Tool execution duration.
| Type | Labels |
|---|---|
| Histogram | model, tool_name |
Active MCP servers.
| Type | Labels |
|---|---|
| Gauge | None |
Tool loop iterations in Responses API.
| Type | Labels |
|---|---|
| Counter | model |
Metrics for storage operations.
Database operations.
| Type | Labels |
|---|---|
| Counter | storage_type, operation, result |
Storage types: response, conversation, conversation_item
Operations: get, put, delete, list
Database operation duration.
| Type | Labels |
|---|---|
| Histogram | storage_type, operation |
Active database connections.
| Type | Labels |
|---|---|
| Gauge | storage_type |
Items stored in database.
| Type | Labels |
|---|---|
| Counter | storage_type |
Entries in the cache-aware routing cache.
| Type | Labels |
|---|---|
| Gauge | None |
Active routing keys per worker (used by cache-aware policies).
| Type | Labels |
|---|---|
| Gauge | worker |
Manual policy execution branch counts for routing decisions.
| Type | Labels |
|---|---|
| Counter | branch |
Consistent hashing policy execution branch counts for routing decisions.
| Type | Labels |
|---|---|
| Counter | branch |
Prefix hash policy execution branch counts for routing decisions.
| Type | Labels |
|---|---|
| Counter | branch |
| Metric | Query |
|---|---|
| Request rate | sum(rate(smg_http_requests_total[5m])) |
| Error rate | sum(rate(smg_http_responses_total{status_code=~"5.."}[5m])) / sum(rate(smg_http_responses_total[5m])) |
| P99 latency | histogram_quantile(0.99, rate(smg_http_request_duration_seconds_bucket[5m])) |
| TTFT P50 | histogram_quantile(0.5, rate(smg_router_ttft_seconds_bucket[5m])) |
| Tokens/sec | sum(rate(smg_router_tokens_total[5m])) |
| Healthy workers | sum(smg_worker_health) |
| Open circuits | count(smg_worker_cb_state == 1) |
| Rate limit rejections | rate(smg_http_rate_limit_total{result="rejected"}[5m]) |
| MCP tool success rate | sum(rate(smg_mcp_tool_calls_total{result="success"}[5m])) / sum(rate(smg_mcp_tool_calls_total[5m])) |
Default histogram buckets (29 buckets from 1ms to 7200s) applied to every metric whose name ends with duration_seconds:
0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0,
10.0, 15.0, 30.0, 45.0, 60.0, 90.0, 120.0, 180.0, 240.0, 300.0,
480.0, 900.0, 1200.0, 1800.0, 2700.0, 3600.0, 5400.0, 7200.0
Configure custom buckets via CLI:
smg --prometheus-duration-buckets 0.01 0.1 0.5 1 5 10