Run in production
Monitor KVStash with Prometheus and Grafana
The daemon exports Prometheus metrics and a health check on one port. They tell you whether engines really read from the store, which tier serves them, and when a tier needs attention.
Last updated
Endpoints
/metricsonmetrics_addr, 127.0.0.1:9442Prometheus text format: every
kvb_family below plus the standard Go process metrics./healthzsame portokwith HTTP 200 once the daemon is ready; HTTP 503 withstartingbefore that. Use it for readiness checks; the Helm chart's probes do./debug/pprofonpprof_addr, off by defaultGo profiling, loopback only. For a remote box, tunnel:
ssh -L 9443:127.0.0.1:9443 host.
Set metrics_addr to a private address (or 0.0.0.0:9442 in a container) so Prometheus can reach it.
Scrape with Prometheus
scrape_configs:
- job_name: kvblockd
static_configs:
- targets: ["10.0.0.5:9442"] # metrics_addr kvb_op_seconds is a native histogram. Start Prometheus with --enable-feature=native-histograms to get latency percentiles from it; the mean works without.
Prove engines use the store
The engine's own logs show whether a connector loaded, not whether it helps. These queries show whether blocks are written, found and served.
# hit ratio per namespace id over 5 minutes
sum by (ns) (rate(kvb_hits_total[5m]))
/ (sum by (ns) (rate(kvb_hits_total[5m])) + sum by (ns) (rate(kvb_misses_total[5m])))
# bytes served to engines per second
sum by (ns) (rate(kvb_bytes_total{dir="out"}[5m]))
# where reads are served from
sum by (tier) (rate(kvb_hits_total[5m])) For one long prompt you can also count exactly: a 524,231-token prompt at 64 tokens per block is 8,191 blocks, so one warm request raises kvb_hits_total by 8,191. Our 524k benchmark checks that count for every timed request.
Grafana dashboard
One dashboard covers throughput, hit ratio, latency, tier residency, tenants against quotas, the S3 tier and NVMe pressure. It uses only metric names the daemon exports.
- Import: Grafana, Dashboards, New, Import, upload the file, then pick your Prometheus data source in the variable at the top left.
- The p99 panel needs native histograms enabled in Prometheus; the mean-latency panel next to it works everywhere.
- Tenant panels: traffic counters are labelled by namespace id, quota gauges by namespace name.
- NVMe and S3 panels are empty on a DRAM-only daemon; those metrics appear once the tier is configured.
What to alert on
Because engines fail open, a broken store shows up as slower first tokens, not as errors. These rules catch the causes. Thresholds are starting points.
groups:
- name: kvblockd
rules:
- alert: KvblockdDown
expr: up{job="kvblockd"} == 0
for: 2m
- alert: KvblockdAuthFailures # an engine with a wrong token serves without cache
expr: increase(kvb_auth_failures_total[10m]) > 0
- alert: KvblockdChecksumErrors
expr: increase(kvb_nvme_checksum_errors_total[1h]) > 0 or increase(kvb_s3_checksum_errors_total[1h]) > 0
- alert: KvblockdNvmeBusy # reads refused because the device pool is saturated
expr: rate(kvb_nvme_read_busy_total[5m]) > 0
for: 10m
- alert: KvblockdS3UploadErrors
expr: increase(kvb_s3_put_errors_total[30m]) > 0
- alert: KvblockdConnectionAborts
expr: increase(kvb_conn_aborts_total[10m]) > 0 Also chart the hit ratio per namespace: a sudden drop after a deploy usually means an engine setting changed its keys (model revision, block size, KV precision, or an unpinned PYTHONHASHSEED).
Metric reference
Traffic
Labels: ns is the namespace id from namespaces.yaml.
kvb_hits_totallabels: tier, nsBlocks found by reads, by the tier that served them.
kvb_misses_totallabels: nsBlocks asked for and not found.
kvb_bytes_totallabels: dir, nsBlock bytes written (dir="in", committed writes) and served (dir="out").
kvb_op_secondslabels: opServer-side handling time per request type (histogram; the socket write is not included).
kvb_get_busy_totallabels: nsKeys answered with ERR_BUSY because NVMe readers were saturated. Engines treat these as misses.
Residency and memory
kvb_blockslabels: tierCommitted blocks resident in each tier.
kvb_store_byteslabels: tierBytes resident in each tier.
kvb_arena_byteslabels: stateDRAM arena: total, free and largest free region.
kvb_evictions_totallabels: tierBlocks evicted under memory pressure.
kvb_eviction_ghost_bytesMemory the eviction policy uses for its history, held outside the arena.
kvb_pinned_byteslabels: nsPinned bytes charged to each namespace.
kvb_live_allocs, kvb_max_allocslabels: tierAllocator extents in use and its capacity.
Tenants
Labels: namespace is the name, tier is dram, nvme or s3.
kvb_tenant_byteslabels: namespace, tierBytes charged to each tenant.
kvb_tenant_quota_byteslabels: namespace, tierConfigured quota (0 = unlimited).
kvb_tenant_physical_byteslabels: namespace, tierFlash and S3 capacity reserved for the tenant in whole segments, which NVMe and S3 quotas are checked against.
NVMe tier
Present once nvme_paths is set.
kvb_nvme_used_bytes, kvb_nvme_max_bytesSpace used across volumes, and the configured budget.
kvb_nvme_segmentsLive segment files.
kvb_nvme_demotions_totalBlocks moved from DRAM to NVMe.
kvb_nvme_promotions_totalBlocks moved back to DRAM (second hit in the window, or a hard pin).
kvb_nvme_admit_refusals_totalBlocks dropped at demotion because they had fewer reads than nvme_admit_min_hits.
kvb_nvme_demote_drops_total, kvb_nvme_promote_drops_totalMoves skipped because a queue was full or a write failed. A dropped promotion is a missed speedup, not lost data.
kvb_nvme_dram_only_evictions_totalBlocks evicted from DRAM before they reached flash, so they are gone (0.2.3 and later). Usually writes outran demotion; if it climbs, see write bursts on the NVMe tier page.
kvb_nvme_reclaims_total, kvb_nvme_reclaim_skips_totalSegments reclaimed, and reclaim rounds that skipped a segment holding protected blocks.
kvb_nvme_read_busy_totalDevice reads refused because the reader pool was full.
kvb_nvme_dedup_skips_totalDemotions skipped because the block was already on flash.
kvb_nvme_checksum_errors_totalDevice reads that failed verification. They are not served; the index repairs itself.
kvb_nvme_recovered_blocks, kvb_nvme_recovery_secondsBlocks recovered at the last startup, and how long it took.
kvb_nvme_demote_hits_sum, kvb_nvme_reaccess_gap_ms_sum, kvb_nvme_reaccess_countTuning aids: how hot the demoted blocks were, and the average gap between re-reads on NVMe.
S3 tier
Present once s3_bucket is set.
kvb_s3_spilled_segments_totalSegments uploaded as objects.
kvb_s3_spill_drops_totalUploads not queued because the queue was full; the segment stays local and is retried.
kvb_s3_put_errors_totalFailed uploads.
kvb_s3_ranged_gets_total, kvb_s3_hits_totalCold block reads issued, and those served after verification.
kvb_s3_restores_totalWhole segments brought back to NVMe after repeated cold reads.
kvb_s3_read_errors_total, kvb_s3_checksum_errors_totalCold reads that timed out, failed, or failed verification; each answered as a miss.
Health
kvb_auth_failures_totalRejected connections (wrong namespace or token). No address or token is recorded.
kvb_conn_aborts_totallabels: statusConnections closed for a protocol error: bad header checksum, credit violation, unsupported version.
kvb_ops_serve_failed1 if the metrics HTTP server stopped with an error.
kvb_stats_decode_errors_totalInternal stats documents the collector could not read; tier gauges go blank when this rises.
The stats document
kvbctl stats returns the daemon's own JSON view: arena size and free space, blocks, bytes, evictions, allocator use, and per-tier sections once NVMe and S3 are on. It needs a namespace token like any data-plane call.
kvbctl stats -ns demo
# {"arena_bytes":1073741824,"arena_free_bytes":1073737728,"blocks":1,"bytes":6,
# "evictions_total":0,"hugepages":false,"live_allocs":1,"max_allocs":16384,
# "pinned_bytes":{},"schema":1,"shard_count":256,"store":"dram", ...} Something missing or wrong on this page? Email rudray@kvstash.com and it gets fixed.