# Observability

> Built-in dashboards and sessions, the Prometheus /metrics endpoint with an optional bearer token, the exported metric names, and OpenTelemetry traces, metrics and logs.

Source: https://neurouter.com/docs/observability · Last updated: 2026-11-24

Neurouter measures every call and exposes the data three ways: built-in dashboards, a Prometheus endpoint and OpenTelemetry.

## Built-in dashboards

*Audit & observability → Overview* shows tool calls, success and error rates, blocked calls and latency (p50, p95, p99), broken down by server, tool, agent and user. Data comes from per-minute rollups, kept for 14 days, and hourly rollups, kept for 400 days.

*Sessions* groups calls into sessions. Because the current MCP specification has no protocol sessions, a session is identified by, in order: a client-supplied `_meta["dev.neurouter/session-id"]`, the trace ID from `traceparent`, the legacy `Mcp-Session-Id` header, or a 30-minute idle gap per agent.

## Prometheus

`GET /metrics` serves Prometheus text format when `METRICS_ENABLED=true` (the default). If `METRICS_TOKEN` is set, scrapers must send it:

```yaml
scrape_configs:
  - job_name: neurouter
    metrics_path: /metrics
    authorization:
      type: Bearer
      credentials: <METRICS_TOKEN>
    static_configs:
      - targets: ["neurouter:3000"]
```

On Kubernetes, set `metrics.serviceMonitor.enabled=true` (and `metrics.token`) in the Helm chart.

Metrics include:

| Metric | What it measures |
|---|---|
| `neurouter_mcp_requests_total` | MCP requests |
| `neurouter_tool_calls_total` | Tool calls |
| `neurouter_tool_call_duration_seconds` | Tool call latency |
| `neurouter_upstream_request_duration_seconds` | Latency of calls to upstream servers |
| `neurouter_upstream_up` | Upstream server health |
| `neurouter_upstream_circuit_open` | Upstream circuit breakers that are open |
| `neurouter_rate_limited_total` | Calls rejected by rate limits |
| `neurouter_auth_failures_total` | Failed authentications |
| `neurouter_approvals_pending` | Calls waiting for approval |
| `neurouter_approval_wait_seconds` | Time calls waited for approval |
| `neurouter_audit_queue_depth` | Audit events waiting to be written |
| `neurouter_audit_flush_seconds` | Audit write latency |
| `neurouter_audit_dropped_total` | Audit events dropped |
| `neurouter_embedding_queue_depth`, `neurouter_embedding_seconds` | Tool search indexing |

## OpenTelemetry

OpenTelemetry is off by default. Enable it with `OTEL_SDK_DISABLED=false` and configure it with the standard variables:

```bash
OTEL_SDK_DISABLED=false
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
OTEL_SERVICE_NAME=neurouter
# optional: also export metrics over OTLP
OTEL_METRICS_EXPORTER=otlp
```

- **Traces** are exported over OTLP/HTTP, covering incoming HTTP, outbound upstream calls (which carry `traceparent`) and PostgreSQL.
- **Metrics** go over OTLP too when `OTEL_METRICS_EXPORTER=otlp`. Prometheus `/metrics` is always served.
- **Audit events** can be exported as OTLP logs; enable it in *Settings → Gateway settings → Export*.
- `service.instance.id` is added to the resource attributes automatically.

With Docker Compose, `docker compose --profile otel up` starts a collector that logs what it receives.

## Health checks

`GET /healthz` (liveness, alias `/health`) and `GET /readyz` (database and audit store).
