---
title: "Observability (metrics and Prometheus)"
description: "Unified OpenTelemetry metrics common to Community and Enterprise. The `GET /metrics` endpoint, scraper authentication, naming, and migration."
canonical_url: "https://surrealdb.com/docs/operate/observability/observability"
section: "Observability"
surrealdb_version: "4.x"
last_modified: "2026-11-18T02:09:16Z"
---

> Full SurrealDB documentation index: https://surrealdb.com/docs/llms.txt

# Observability (metrics and Prometheus)

Unified OpenTelemetry metrics common to Community and Enterprise. The `GET /metrics` endpoint, scraper authentication, naming, and migration.

For server log output (stderr, files, JSON, sockets, slow-query lines), see [Logging](/docs/operate/observability/logging.md).

This page describes SurrealDB 3.1 and later, and [Before SurrealDB 3.1](#before-surrealdb-31) covers earlier versions. For OTLP (push), process intervals, and legacy SemConv instruments on the wire, see [Telemetry (OTLP)](/docs/operate/observability/telemetry.md). For audit and slow-query file sinks, and OTLP log export opt-ins, see [Enterprise observability](/docs/operate/observability/enterprise-observability.md).

SurrealDB exposes a single, unified observability surface backed by OpenTelemetry. Every metric is recorded once and fanned out to whichever exporters you configure:

- **Prometheus (pull)** - text exposition at `GET /metrics` (scrapers call your server). The usual path if you already run Prometheus.
- **OTLP (push)** - when `SURREAL_TELEMETRY_PROVIDER=otlp` is set, the process pushes metrics, traces, and (when enabled) log records to a collector.

**SurrealDB Enterprise** can additionally attach durable **audit** and **slow-query** pipelines; OTLP export of audit and slow-query **log** records is **opt-in** per pipeline. See [Enterprise observability](/docs/operate/observability/enterprise-observability.md).

For OTLP configuration, push intervals, process gauges, and backward-compatible HTTP/RPC instruments, see [Telemetry (OTLP)](/docs/operate/observability/telemetry.md).

To inspect async tasks and scheduling inside the Tokio runtime, see [Tokio console](/docs/operate/observability/tokio-console.md).

## Unified model (summary)

```text
HTTP / WS / Executor → ExecutionObserver → FanOutObserver
                                            ├── MetricsObserver         (labelled surrealdb.*)
                                            ├── AuditObserver           (Enterprise, when configured)
                                            └── SlowQueryObserver       (Enterprise, when configured)
                                                       │
                                                       ▼
                                            SdkMeterProvider + SdkLoggerProvider
                                                       │
                                       ┌───────────────┼────────────────┐
                                       ▼               ▼                ▼
                          Prometheus text       OTLP metrics push   OTLP logs / traces push
                          exporter (/metrics)
```

Metrics are recorded once in labelled form. A single `surrealdb.statement` counter, for example, carries `statement_type`, `outcome`, `namespace`, `database`, and `user` in **Community and Enterprise**; unresolved tenant context appears as a `"-"` sentinel so series stay stable. Build flavour (`community` vs `enterprise`) is exposed on the OpenTelemetry **resource** as `service.edition` (for example on `target_info` in Prometheus) - use that attribute for edition-aware dashboards instead of filtering on meter scope alone.

When no exporter is configured, the fan-out short-circuits so the hot path stays fast.

## Naming (summary)

Instruments use dotted OpenTelemetry-style names (for example `surrealdb.statement.duration`) under signal-domain scopes (`surrealdb.statement`, `surrealdb.query`, …). The Prometheus text exporter maps those to underscore names with conventional `_total`, `_seconds`, and `_bytes` suffixes. Attribute keys with dots are sanitised for Prometheus.

Many historical Prometheus series names and label shapes changed in SurrealDB 3.1. Dashboards that pre-date that release should be updated using the migration table in [`doc/OBSERVABILITY.md`](https://github.com/surrealdb/surrealdb/blob/main/doc/OBSERVABILITY.md) (and the Enterprise companion for **[E]**-only series).

## Metrics on or off

| Switch | Default | Effect |
| --- | --- | --- |
| `SURREAL_METRICS_ENABLED` | `true` | When `false`, the `/metrics` route is not mounted |
| `SURREAL_TELEMETRY_PROVIDER` | unset | Set to `otlp` to enable the OTLP push pipeline (metrics, logs, traces) |
| `SURREAL_TELEMETRY_DISABLE_METRICS` | `false` | When `true`, suppresses the OTLP metrics reader (logs and traces unaffected) |
| `SURREAL_TELEMETRY_DISABLE_TRACING` | `false` | When `true`, suppresses the OTLP trace exporter only |

When metrics are disabled, `/metrics` returns 404.

## Collecting `/metrics` and security

Anonymous scrapes only receive families on a public allowlist (aggregate process signals). Root credentials unlock the full Prometheus surface for that process; namespace and database users are not treated as authenticated for this endpoint. Dimensional families such as `surrealdb_statement_total` are intentionally excluded from anonymous output because they carry tenant labels - use OTLP or an authenticated scrape for those. See [`doc/OBSERVABILITY.md`](https://github.com/surrealdb/surrealdb/blob/main/doc/OBSERVABILITY.md) for the `PUBLIC_METRICS` list and security discussion.

## Audit and slow-query (summary)

**Community** builds do not ship the enterprise audit and slow-query file pipelines or their pipeline self-metrics on Prometheus.

**Enterprise** can write tamper-aware NDJSON to disk **and** optionally emit the same redacted records as OpenTelemetry logs when `SURREAL_AUDIT_OTEL_EXPORT=true` / `SURREAL_SLOW_QUERY_OTEL_EXPORT=true` (both default `false`). Redaction runs on the executor thread before the queue so every sink sees the same scrubbed payload. See [Enterprise observability](/docs/operate/observability/enterprise-observability.md) and `SURREAL_AUDIT_*` / `SURREAL_SLOW_QUERY_*` in [Environment variables](/docs/reference/cli/db/environment-variables.md).

## Multi-tenant guidance

Treat `/metrics` as operator-only in multi-tenant deployments: avoid exposing the main listener to untrusted scrapers, prefer disabling metrics if you cannot isolate the endpoint, and never give tenants root credentials used for the authenticated metric view.

## Local development

Compare anonymous and authenticated scrapes:

```bash
curl http://127.0.0.1:8000/metrics
curl -u root:secret http://127.0.0.1:8000/metrics
```

Disable metrics entirely:

```bash
SURREAL_METRICS_ENABLED=false surreal db start ...
```

Push metrics, logs, and traces to a local collector:

```bash
SURREAL_TELEMETRY_PROVIDER=otlp \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
surreal db start ...
```

For OTLP-focused setup and version tabs, see [Telemetry (OTLP)](/docs/operate/observability/telemetry.md). For catalogue-level detail, use the in-repository `doc/OBSERVABILITY.md` / `doc/TELEMETRY.md` files linked above (and the Enterprise `doc/OBSERVABILITY.md` where applicable). For every instrument name, label, and alert hint on this site, see the [Metrics reference](/docs/operate/observability/metrics.md).

## Before SurrealDB 3.1

Prior to SurrealDB 3.1, operators often saw overlapping metric paths: built-in Prometheus exposition could run alongside a separate OpenTelemetry pipeline oriented around HTTP/RPC semantic conventions. The same request could therefore be reflected more than once, under different scopes and label keys (for example `http.server.*` / `rpc.server.*` versus `surrealdb.*`-style families).

Many deployments also emitted parallel families for the same logical signal - aggregate counters or histograms plus higher-cardinality “dimensional” variants (names with a `*_dim_*` segment, or separate `*_errors_total` series). Dashboards and alerts had to choose which family to query, and mixing them could double-count.

Edition (`community` vs `enterprise`) could appear on meter scope identifiers (for example in `otel_scope_name` after export to Prometheus). That tied dashboards to build flavour at the scope level and made renames risky.

Tenant context (namespace, database, user, and similar) could be attached to labels in more ad hoc ways across recording sites, so you should treat unauthenticated `/metrics` scrapes as potentially sensitive in multi-tenant layouts unless you had a deliberate proxy or allowlist in front of the endpoint.

For the OTLP side of the same era (push interval, `http.server.*` / `rpc.server.*` instruments, deprecated variables), see [Before SurrealDB 3.1](/docs/operate/observability/telemetry.md#before-surrealdb-31) on the Telemetry (OTLP) page.

When you upgrade to 3.1 or later, replan dashboards and alerts using the migration material in [`doc/OBSERVABILITY.md`](https://github.com/surrealdb/surrealdb/blob/main/doc/OBSERVABILITY.md) in the open-source repository (and the Enterprise companion, if you run SurrealDB Enterprise).
