05 · ENGINE
Metrics
GET /v1/metrics returns Prometheus text format. Every metric below is emitted unconditionally and has per-index labels where it makes sense.
Counters
docs_indexedTotal docs written.
queries_executedTotal queries served.
bytes_writtenBytes to segment + WAL.
bytes_readBytes read back from segments.
rerank_requestsSearches that carried a rerank block, by outcome: applied, degraded, refused (nothing sent), failed.
rerank_documents_judgedDocuments the rerank provider returned a verdict for — the billing unit.
rerank_provider_tokensTokens the rerank provider reported, by kind: input, output.
Histograms
query_latencyFull query path, in seconds.
index_latencyMemtable + WAL write path.
flush_durationMemtable → segment flush.
merge_durationSegment merge time.
wal_write_latencyWAL fsync latency.
Gauges
segment_countLive segments per index.
doc_countVisible docs per index.
memory_usageRSS in bytes.
active_searchesIn-flight queries.
wal_size_bytesLive WAL size.
Cluster and memory breaker
These are read from the node's own state each time /v1/metrics is scraped. On a single node, which has no cluster ring, the xerj_raft_* gauges and xerj_cluster_members read 0 and there are no xerj_shard_* series. Each member reports the shard table from its own applied Raft log, so the members agree once they have applied the same entries.
xerj_raft_termThis node's current Raft term.
xerj_raft_is_leader1 on the Raft leader, 0 elsewhere. Across a healthy ring the sum is 1.
xerj_raft_commit_indexHighest log index this node knows is committed.
xerj_raft_applied_indexHighest log index this node has applied.
xerj_raft_apply_lagCommitted entries not yet applied here.
xerj_cluster_membersMembers of the configured ring, this node included. It does not track which peers are up.
xerj_shard_placed_replicasReplicas placed for a shard at create, less any replica later promoted to primary, by index and shard. The primary is not counted.
xerj_shard_in_sync_replicasReplicas currently in sync, by index and shard. Lower than placed means the shard is under-replicated.
xerj_replication_nacks_totalCounter, on the primary. Each in-sync replica that did not confirm a write the primary applied, including a write the primary could not copy at all. It is removed from the in-sync set when that shrink commits through Raft; if the shrink does not commit, it stays listed and each later write it misses counts again.
xerj_replica_backfill_docs_totalCounter, on the primary. Documents copied onto a lagging replica by backfill passes that put it back in sync.
xerj_breaker_engaged1 while a parent breaker is engaged, by breaker: memory (RSS) or memtable. While it is 1, writes get HTTP 429.
xerj_breaker_rejections_totalCounter. Refusals the memory governor returned as a 429 circuit_breaking_exception, by breaker: memtable, memory, analyze, read_transient, search, query (limits.max_query_memory_mb). It counts refusing calls, not HTTP requests: one bulk that touches several indices while a breaker is engaged can add more than 1. Disk flood-stage blocks are not counted here.
xerj_memory_limit_bytesResolved process memory limit. With no cap configured this is the machine's memory size.
xerj_memory_watermark_bytesRSS level at which the memory breaker engages. 0 means the check is off.
Alert examples: sum(xerj_raft_is_leader) != 1, max by (index, shard) (xerj_shard_placed_replicas - xerj_shard_in_sync_replicas) > 0, rate(xerj_breaker_rejections_total[5m]) > 0. These series do not detect a stopped primary: xerj_cluster_members counts configured members, the xerj_shard_* gauges leave the primary out, and nacks are counted only by a primary that is running. To see one, use GET /_cluster/health, which is red while a primary's member does not answer (Clustering). Writes to that shard fail until the member comes back, unless [cluster] primary_failover_timeout_ms is set (off by default). After a promotion the shard runs with one copy fewer and its placed count drops with it, so placed - in_sync does not show the lost copy.
Scrape config
# prometheus.yml
scrape_configs:
- job_name: xerj
metrics_path: /v1/metrics
static_configs:
- targets: ["xerj.internal:8080"]
authorization:
type: Bearer
credentials: ${XERJ_API_KEY}
Source · engine/crates/xerj-common/src/metrics.rs