VeltrixDB Docs
v1.1.0 GitHub FAQ Quickstart

Admin API Reference

The full HTTP surface exposed on -metrics-addr (default :2112): health probes, Prometheus metrics, and the /admin/* operational endpoints implemented in adminapi/admin.go and cmd/server/admin_cluster.go.

Access control (v1.1.0) /admin/* is guarded. With no token configured, admin endpoints accept loopback connections only — a non-loopback request gets 403. Starting the server with -admin-token <token> (or the VELTRIX_ADMIN_TOKEN environment variable) requires every /admin/* request, loopback included, to send Authorization: Bearer <token> or X-Admin-Token: <token>; anything else gets 401. The comparison is constant-time. /metrics, /healthz, and /readyz are not guarded, so Prometheus scrapes and Kubernetes probes need no configuration. Several endpoints still mutate live state (/admin/quotas mutates live limits, /admin/migrate mutates on-disk schema), so treat the token as a second layer: on untrusted networks, keep the port behind a network policy / firewall, and preferably mTLS via a sidecar proxy (Envoy or nginx).

Health and metrics endpoints

These are registered directly in cmd/server/main.go, before the storage engine finishes initializing, so liveness checks never time out during a slow WAL replay.

MethodPathPurpose
GET/healthzLiveness probe. Always returns 200 ok once the HTTP listener is up — it does not depend on the storage engine being ready. Suitable for a Kubernetes livenessProbe.
GET/readyzReadiness probe. Returns 503 initializing until the storage engine has finished startup (WAL replay, VLog device open, etc.), then 200 ready. Suitable for a Kubernetes readinessProbe.
GET/metricsPrometheus exposition endpoint (OpenMetrics-enabled). Backed by veltrixmetrics.NewVeltrixCollector, registered on a dedicated prometheus.Registry. Exposes 60+ metrics covering storage, cache, WAL, VLog GC, replication, and cluster state.
GET/tracesRecent OpenTelemetry-compatible spans from the in-process ring buffer (default retains 2048 spans). Only slow operations (≥50 ms) and errors are guaranteed to appear regardless of the 1% trace sampler. Returned as newline-delimited JSON.
curl http://localhost:2112/healthz
curl http://localhost:2112/readyz
curl http://localhost:2112/metrics | head -30
curl http://localhost:2112/traces

GET /admin/stats

Returns a full JSON snapshot of engine state: index size, cumulative op counters, cache stats, WAL totals, CDC counters, per-disk VLog stats, and namespace list. This is the endpoint the veltrix status, veltrix compaction, veltrix cache, and veltrix top subcommands poll.

curl http://localhost:2112/admin/stats

Response shape (fields read directly from handleStats in adminapi/admin.go):

FieldTypeDescription
index_keysintLive key count in the in-memory index.
writes_totaluint64Cumulative write count.
reads_totaluint64Cumulative read count.
deletes_totaluint64Cumulative delete count.
atomic_ops_totaluint64Cumulative CAS/INCR/DECR/SETNX count.
audit_dropped_totaluint64Audit log entries dropped (e.g., due to a full write queue).
cacheobjectstorage.CacheStats — LIRS cache size, capacity, hits, misses, evictions.
wal_bytesuint64Total bytes written to the WAL across all disks.
wal_entriesuint64Total WAL entry count across all disks.
cdc_broadcast_totaluint64Total CDC events broadcast to subscribers.
cdc_dropped_totaluint64CDC events dropped due to slow consumers.
cdc_subscribersintCurrent active CDC subscriber count.
vlogsarrayPer-disk storage.VLogStats — size, live bytes, GC ratio, one entry per disk.
namespacesarraystorage.NSInfo list — namespace name and key count, one entry per namespace.

GET /admin/version

Returns the on-disk schema version and whether at-rest encryption is enabled.

curl http://localhost:2112/admin/version
FieldTypeDescription
current_schema_versionintstorage.CurrentSchemaVersion — the schema version this binary writes.
encryption_enabledboolWhether AES-256-GCM at-rest encryption is active on this node.

POST /admin/checkpoint

Forces an immediate WAL checkpoint across all disks. Synchronous — the HTTP response is delayed until the checkpoint completes.

curl -X POST http://localhost:2112/admin/checkpoint
FieldTypeDescription
statusstring"ok" on success.
duration_msint64Wall-clock time the checkpoint took.

Non-POST requests receive 405 GET or POST is not accepted here — only POST is allowed.

GET / POST /admin/quotas

Reads or mutates per-namespace rate-limit and key-count quotas (token-bucket write throttling plus a hard key-count cap).

GET — list current quotas

curl http://localhost:2112/admin/quotas

Returns a JSON array of storage.QuotaSnapshot objects, one per namespace with a configured limit.

POST — set a namespace quota

Accepts form-encoded parameters (not JSON):

Form fieldDescription
nsNamespace name to configure.
writes_per_secSustained write-rate limit (token bucket refill rate).
burstToken bucket burst capacity.
max_keysHard cap on key count in the namespace (int64).
curl -X POST http://localhost:2112/admin/quotas \
  -d "ns=tenant_42&writes_per_sec=5000&burst=10000&max_keys=1000000"

Response: {"status": "ok", "ns": "tenant_42"}.

POST /admin/migrate

Runs schema migrations across all keys currently below current_schema_version.

curl -X POST http://localhost:2112/admin/migrate
FieldTypeDescription
migratedintNumber of records successfully migrated.
errorsintNumber of records that failed migration.
target_schemaintThe schema version records were migrated to.

This is also the endpoint kubectl veltrix migrate calls (see CLI Reference).

GET /admin/cdc

Streams live change-data-capture events as newline-delimited JSON (application/x-ndjson) until the client disconnects, an optional duration elapses, or the subscription is evicted for being a slow consumer.

Query paramDefaultDescription
prefix(all keys)Only stream events for keys matching this prefix.
duration_seconds0 (unlimited)Automatically close the stream after N seconds.
buffer1024Per-subscriber channel buffer size; slow consumers that fall behind this buffer are evicted.
curl "http://localhost:2112/admin/cdc?prefix=orders/&duration_seconds=60"

Each streamed line is one JSON-encoded storage.CDCEvent (operation type, key, and related metadata — consumed directly by veltrix cdc-tail and by the repl-ship cross-region shipper).

The live CDC stream is in-process only Events are held in an in-memory channel per subscriber, so a consumer (e.g. repl-ship) that is down when an event fires misses it on this stream. As of v1.1.0, the durable /admin/changes catch-up feed closes that gap: repl-ship --checkpoint replays exactly the delta it missed before rejoining the live stream.

GET /admin/changes

v1.1.0 The durable catch-up feed backing cross-region replication (storage.ChangesSince). Where /admin/cdc streams live events, /admin/changes scans the index for entries written at or after a microsecond cursor — so a shipper that persists its "last shipped timestamp" can replay the delta it missed while down, then rejoin the live stream. This is what repl-ship --checkpoint calls on restart.

Query paramDefaultDescription
since0Microsecond timestamp cursor (WriteTimestampUs). The boundary is inclusive (>= since).
limit10000Maximum events per page; values ≤ 0 or > 100,000 are reset to 10,000.
curl "http://localhost:2112/admin/changes?since=1752800000000000&limit=1000"

The response is newline-delimited JSON (application/x-ndjson): one storage.CDCEvent per line (Op "PUT" or "DEL", Key, Value — empty for deletes — and Timestamp in µs), ordered by write timestamp, followed by a single trailer line:

{"Op":"PUT","Key":"orders/1042","Value":"...","Timestamp":1752800000123456}
{"Op":"DEL","Key":"orders/0999","Timestamp":1752800000234567}
{"cursor":1752800000234567,"more":false}
Trailer fieldTypeDescription
cursorint64 (µs)Resume point for the next page — the timestamp of the last event returned (or the request's since when no events matched). Pass it back as the next request's since.
moreboolWhether entries beyond this page matched the scan.

Semantics worth knowing before building on it:

POST /admin/backup

Triggers a full or incremental backup from a live engine, writing to a local destination directory on the server's filesystem. Only registered when the server is started with a non-nil BackupEngine (always true for cmd/server).

Request body (JSON):

{
  "type": "full",
  "dest_dir": "/backup/2026-07-05",
  "base_dir": ""
}
FieldRequiredDescription
typeNo"full" (default) or "incremental".
dest_dirYesLocal destination directory on the server host.
base_dirOnly for incrementalPath to the base backup's manifest, used to compute the delta.
curl -X POST http://localhost:2112/admin/backup \
  -H "Content-Type: application/json" \
  -d '{"type":"full","dest_dir":"/backup/2026-07-05"}'

Response includes status, type, backup_id, dest_dir, num_disks, duration_ms, and the full manifest object. This is what veltrix backup DEST_DIR calls under the hood.

GET /admin/cluster (alias: /admin/topology)

Returns the live distributed-layer topology: node role, Raft term/leader (in raft mode), replication lag (in replicated mode), partition count, and fencing epoch. Registered separately from the rest of the admin API, in cmd/server/admin_cluster.go, via registerClusterAdmin.

curl http://localhost:2112/admin/cluster
FieldTypeDescription
node_idstringThis node's ID.
modestringstandalone, raft, or replicated.
epochuint64Partition-map fencing epoch.
partition_countuint32Number of partitions in the consistent-hash ring.
consistencystringPresent only in replicated mode — eventual/quorum/strong.
raftobjectPresent only in raft mode: role, term, leader_id, is_leader.
replicationarrayPresent only in replicated mode: per-replica node_id, state, last_ack_seq, lag_bytes, lag_ns.
nodesarrayEvery known node: node_id, address, port, state.

This is the endpoint the bundled cluster-aware client (client.NewClient) calls to bootstrap consistent-hash routing and discover the current Raft leader, and it is what veltrix nodes renders as a table.

GET /admin/ui

Serves the built-in HTML/JS web dashboard (implemented in adminapi/ui.go). Also mounted as the catch-all at /admin/, so any unmatched path under /admin/ falls through to the dashboard.

open http://localhost:2112/admin/ui

Endpoint summary

MethodPathAuthPurpose
GET/healthznoneLiveness probe
GET/readyznoneReadiness probe
GET/metricsnonePrometheus scrape endpoint
GET/tracesnoneRecent slow/error OTel spans
GET/admin/statsloopback / tokenFull engine snapshot
GET/admin/versionloopback / tokenSchema version + encryption flag
POST/admin/checkpointloopback / tokenForce WAL checkpoint
GET/POST/admin/quotasloopback / tokenRead or set per-namespace quotas
POST/admin/migrateloopback / tokenRun schema migrations
GET/admin/cdcloopback / tokenStream CDC events (NDJSON)
GET/admin/changesloopback / tokenDurable change-feed catch-up (NDJSON + cursor trailer)
POST/admin/backuploopback / tokenTrigger full/incremental backup
GET/admin/cluster, /admin/topologyloopback / tokenCluster topology, Raft/replication state
GET/admin/ui, /admin/* (catch-all)loopback / tokenWeb dashboard