Observability

Every Cognitora binary emits the same three pillars: structured logs (JSON via tracing), metrics (Prometheus over an admin HTTP port), and traces (OTLP when an endpoint is configured). cgn-telemetry initialises all three in a single init(service) call so the wire format is identical across binaries.

Logs

tracing-subscriber with the JSON formatter writes one event per line to stdout. Fields the platform always emits:

FieldTypeNotes
timestampRFC3339UTC
levelstringINFO/WARN/ERROR/DEBUG
fieldsobjectmessage plus event fields, such as node and overlap on routing decisions
targetstringtracing target (Rust module path)

Override the level with RUST_LOG=cgn_router=debug,info.

Metrics

Each binary serves Prometheus on its admin port:

BinaryPort
cgn-router:9091
cgn-agent:9091
cgn-kvcached:9091
cgn-metrics:9092

cgn-metrics federates the per-host endpoints and exposes the union on :9092, plus the power gauges from cgn-power.

All /metrics listeners send Access-Control-Allow-Origin: *, so any browser app can scrape them directly, including the bundled standalone cluster dashboard, which charts req/s, tokens/s, latency + TTFT percentiles, per-node status, KV utilisation, power, and J/token with no Prometheus server required.

The router additionally mirrors its live node registry into cgn_cluster_node_* gauges (up, cordoned, queue_depth, kv_free_blocks, kv_total_blocks, power_watts, info) refreshed every 5 s, plus cgn_cluster_nodes_total and cgn_router_prefix_index_digests. Gateway traffic is covered by cgn_router_chat_requests_total, cgn_router_chat_completion_tokens_total, cgn_router_chat_latency_seconds, and cgn_router_chat_ttft_seconds (time from dispatch to first streamed token).

Core series

MetricTypeLabels
cgn_router_chat_requests_totalcountermodel, status
cgn_router_chat_latency_secondshistogrammodel, stream
cgn_router_chat_ttft_secondshistogrammodel
cgn_router_chat_completion_tokens_totalcountermodel
cgn_router_routing_decision_secondshistogrammodel
cgn_router_prefix_overlap_ratiohistogrammodel
cgn_router_tenant_tokens_totalcountertenant, kind
cgn_router_token_limit_rejected_totalcounterlimit
cgn_router_rate_limited_totalcounter—
cgn_router_admission_inflightgaugemodel, role
cgn_router_admission_waitinggaugemodel
cgn_router_admission_rejected_totalcountermodel, reason
cgn_router_cascade_confidence_totalcountersource
cgn_router_tokenizer_fallback_totalcountermodel
cgn_router_federation_forwards_totalcountermodel, peer
cgn_router_prefix_index_digestsgauge—
cgn_router_prefix_index_pruned_totalcounternode, reason
cgn_router_carbon_admission_rejected_totalcounter—
cgn_carbon_intensity_gco2_per_kwhgaugezone
cgn_cluster_nodes_totalgauge—
cgn_cluster_node_up, _cordoned, _queue_depth, _power_watts, _watt_limit, _kv_free_blocks, _kv_total_blocks, _vram_total_mb, _infogaugenode, plus identity labels on _info
cgn_cluster_power_watts_totalgauge—
cgn_cluster_tokens_per_wattgauge—
cgn_power_watts_gpu, cgn_power_watts_chassisgaugesee cgn-metrics
cgn_metrics_scrape_errors_totalcountersee cgn-metrics

cgn-agent and cgn-kvcached export no Prometheus metrics of their own yet. Node health reaches Prometheus through the router's cgn_cluster_node_* gauges, and the block cache reports through its Kv.Stats RPC. cgn_cluster_node_up is 1 for a node that is ready and not draining.

cgn_router_prefix_overlap_ratio is what the router believes a node holds, not a measured engine cache hit rate.

cgn_cluster_power_watts_total sums cgn_cluster_node_power_watts across live nodes (refreshed every 5 s). cgn_cluster_tokens_per_watt is the recent completion-token rate divided by fleet power — use it with scripts/bench/energy/ or scripts/bench/proof/ for J/token numbers.

status is 200, a client or overload code such as 400 or 429, or 5xx for every server fault. reason ∈ {queue_full, wait_timeout, ttft_violation}. limit ∈ {tpm, budget}. source ∈ {logprobs, heuristic}. kind ∈ {prompt, completion}.

Traces

Set OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 and every binary exports OTLP/gRPC spans from tracing. The router's HTTP trace layer is the main source; there are no custom routing or engine spans yet.

W3C traceparent and tracestate from the client are forwarded to agents in the gRPC request, but the agent does not continue the trace yet.

Dashboards

A starter Grafana dashboard ships at deploy/kubernetes/helm/cognitora/dashboards/cognitora.json. Set metrics.dashboards.enabled = true in the Helm values to mount it into a grafana_dashboard=1 ConfigMap that the kube-prometheus-stack Grafana sidecar picks up automatically. Panels:

  • Latency: routing-decision p99, TTFT p99 per model
  • Prefix overlap, requests by status, in-flight by model
  • Power per node

Alerting

The chart ships both halves of alerting, off by default. Both need the prometheus-operator CRDs:

helm upgrade cognitora ... \
  --set metrics.serviceMonitor.enabled=true \
  --set metrics.prometheusRule.enabled=true

serviceMonitor adds a ClusterIP Service for the router's admin port and scrapes it. If you scrape another way, set metrics.prometheusRule.routerJob to your job label, or the router-down alerts will look for the wrong job. Your Prometheus must also select these objects, which usually means copying its selector into metrics.serviceMonitor.labels and metrics.prometheusRule.labels.

AlertSeverityFires when
CognitoraRouterDownpageA router scrape fails for 1 min
CognitoraRouterNotScrapedpageNo router targets exist for 5 min, which would silence everything below
CognitoraNoNodespageThe router sees no nodes for 2 min
CognitoraHighErrorRatiopageServer errors exceed thresholds.errorRatio (5%) for 5 min
CognitoraNodeLostwarnFewer nodes than at any point in the last hour; clears an hour after a scale-down
CognitoraAgentNotReadywarnA node is unready or draining for 5 min on every router
CognitoraTtftSlowarnTTFT p99 exceeds thresholds.ttftP99Seconds (2.5 s) for 10 min
CognitoraRoutingDecisionSlowarnRouting decision p99 exceeds 500 µs for 10 min
CognitoraAdmissionRejectingwarnRequests are rejected at admission for 5 min
CognitoraWaitQueueBacklogwarnRequests stay parked in wait queues for 10 min
CognitoraNodeOverPowerCapwarnA node stays above its watt_limit for 15 min
CognitoraLowPrefixOverlapinfoMean overlap is below thresholds.minPrefixOverlap (0.1) for 30 min
CognitoraTokenizerFallbackinfoA model has been using the estimate instead of a tokenizer for 30 min

Set the TTFT threshold from your tier in SLOs; the histogram's top bucket is 10 s, so it can't see beyond that. Overload (429) and client errors (400) deliberately don't count towards the error ratio.

CI keeps this honest: scripts/check-helm-metrics.py fails if the chart uses a metric the code doesn't export, and tests/helm/alerts_test.yaml runs the rules through promtool to prove the main alerts fire and stay quiet when they should.