Monitoring and tracing
The gateway's health check, Prometheus metrics and the scrape token, the metric list and common queries, the Grafana dashboard, and OpenTelemetry tracing settings.
The gateway exposes Prometheus metrics and OpenTelemetry traces without extra components. Example configuration is in the package's monitoring/ directory.
Health check
GET /healthz returns ok while the gateway is running. It needs no authentication and suits load balancers and process monitors.
Prometheus metrics
Scrape http://<gateway>:8080/metrics with the header Authorization: Bearer <RST_FABRIC_METRICS_TOKEN>. install.sh generates the token and writes it to .env.
Without RST_FABRIC_METRICS_TOKEN, /metrics accepts only direct requests from the gateway host; requests through a reverse proxy or from other machines are refused. The metrics include model names, project IDs, upstream addresses and call volumes, so always set a token for remote scraping and keep it in a file Prometheus can read. If the token leaks, change it in .env and run docker compose up -d.
scrape_configs:
- job_name: rst-ai-fabric
static_configs: [{ targets: ["10.0.0.10:8080"] }]
authorization:
type: Bearer
credentials_file: /etc/prometheus/secrets/rst-fabric-metrics-tokenThe full example is monitoring/prometheus/prometheus.yml. Example alert rules in monitoring/prometheus/alerts.yml cover scrape failures, a high 5xx ratio, rejections from full models, upstreams ejected or all down, p95 latency, p95 time to first token, queue backlog, KV cache saturation, an invalid licence and dropped trace spans. Adjust the thresholds to your models and check the file with promtool check rules alerts.yml.
Metrics
All label values are bounded: model takes only model names configured in the console (requests for unknown models count as unknown); endpoint is chat, completions, embeddings, rerank, score or messages; status is 2xx, 4xx, 429 or 5xx; upstream is the upstream's host:port. Metrics never carry API keys or client IPs.
| Metric | Type | Labels | Description |
|---|---|---|---|
fabric_requests_total | counter | model, endpoint, project, status | Requests |
fabric_errors_total | counter | model, endpoint, code | Failed requests by error code |
fabric_tokens_total | counter | model, type | Tokens; type is prompt or completion |
fabric_cost_total | counter | model | Billed amount (CNY) |
fabric_pii_masked_total | counter | direction, kind | Masked personal information; direction is input or output, kind is phone, id_card, bank_card or email |
fabric_pii_blocked_total | counter | Requests blocked for personal information | |
fabric_request_duration_seconds | histogram | model, endpoint, status | End-to-end time; streams are timed to the last chunk |
fabric_ttft_seconds | histogram | model, endpoint | Streaming time to first token |
fabric_queue_seconds | histogram | model, endpoint | Time spent waiting for a model concurrency slot |
fabric_upstream_request_duration_seconds | histogram | upstream, status | Time per upstream call |
fabric_upstream_attempts_total | counter | upstream | Upstream calls, including retries |
fabric_upstream_failures_total | counter | upstream, reason | Failed upstream calls; reason is transport, http_429 or http_5xx |
fabric_inflight_requests | gauge | model | Requests in progress per model |
fabric_model_queue_depth | gauge | model | Requests waiting for a slot |
fabric_upstream_up | gauge | model, upstream | 1 when the upstream is healthy, 0 when ejected |
fabric_upstream_inflight | gauge | model, upstream | Requests in progress per upstream |
fabric_engine_running, fabric_engine_waiting | gauge | model, upstream | vLLM running and waiting requests |
fabric_engine_kv_cache_usage_ratio | gauge | model, upstream | vLLM KV cache usage, 0 to 1 |
fabric_license_valid | gauge | 1 while the licence is usable | |
fabric_build_info | gauge | version, goversion | Build information, always 1 |
Go runtime metrics (go_*), process metrics (process_*) and, with tracing on, export statistics (fabric_trace_*) are also exposed.
Common queries:
# p95 latency per model (successful requests)
histogram_quantile(0.95, sum by (le, model) (rate(fabric_request_duration_seconds_bucket{status="2xx"}[5m])))
# 5xx ratio
sum(rate(fabric_requests_total{status="5xx"}[5m])) / sum(rate(fabric_requests_total[5m]))
# Failure rate by error code
sum by (code) (rate(fabric_errors_total[5m]))Grafana
In Grafana, choose Dashboards > New > Import, upload monitoring/grafana/rst-ai-fabric.json and pick the Prometheus data source that scrapes the gateway. Panels cover request rate, 5xx ratio, p50 / p95 / p99 latency, time to first token, queue time and depth, failures by error code, upstream health and timing, vLLM running requests and KV cache, tokens and hourly cost, runtime and process. Filter by job and model at the top.
OpenTelemetry tracing
Setting an OTLP endpoint turns tracing on; without one it is fully off. The gateway supports OTLP/HTTP JSON only, usually on port 4318.
Each request produces a SERVER span (named like POST /v1/chat/completions) with HTTP attributes, GenAI semantic convention attributes (requested model, model actually served, input and output tokens and so on) and fabric.request_id, which matches the X-Request-Id response header. Queue waiting and each upstream call get child spans. Spans never contain API keys, prompts, model output or upstream error text.
The gateway accepts traceparent and tracestate from clients as the parent span and injects traceparent towards upstreams, so inference servers with OpenTelemetry support join the same trace. With tracing on, request-related gateway log lines carry trace_id and span_id.
| Setting | Default | Description |
|---|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | Empty (off) | The collector's OTLP/HTTP base URL; the gateway appends /v1/traces. For example http://otel-collector:4318 |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | Empty | Full traces URL, used as is; takes precedence over the above |
OTEL_EXPORTER_OTLP_HEADERS | Empty | Headers such as authentication, k1=v1,k2=v2, values URL-encoded, for example Authorization=Bearer%20xxx |
OTEL_SERVICE_NAME | rst-ai-fabric | service.name |
OTEL_RESOURCE_ATTRIBUTES | Empty | Extra resource attributes, for example deployment.environment=prod |
OTEL_TRACES_SAMPLER | parentbased_always_on | always_on, always_off, traceidratio, parentbased_always_on, parentbased_always_off, parentbased_traceidratio |
OTEL_TRACES_SAMPLER_ARG | 1.0 | Sampling ratio for *traceidratio, 0 to 1 |
Set them in .env and run docker compose up -d. Example with 10% sampling in production:
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=prodSpans are exported in the background in batches. When the queue is full, new spans are dropped and counted in fabric_trace_spans_dropped_total; requests are never blocked.
Sign-in integrations
Local accounts and two-factor authentication, configuring OIDC single sign-on, Feishu sign-in and LDAP / Active Directory, administrator group mapping and automatic provisioning, and sign-in rate limits.
Upgrade and backup
New-version notices, one-click upgrades from the console (online or offline package) with their steps and automatic rollback, manual upgrades, backing up and restoring the database and the key encryption key, and manual recovery after a failed rollback.