CLI (cmd/nokv) Reference
The nokv command provides operational visibility similar to RocksDB’s ldb and Badger’s badger CLI, but emits JSON to integrate easily with scripts and CI pipelines.
Installation
go install ./cmd/nokv
Use GOBIN if you prefer a custom binary directory.
Shared Flags
--workdir <path>– location of the NoKV database (must containCURRENT).--json– emit structured JSON (default is human-readable tables).--expvar <url>– forstatscommand, pull metrics from a running process exposingexpvar.--no-region-metrics– forstatsoffline mode; skip attachingRegionMetricsand report manifest-only figures.
Subcommands
nokv stats
- Reads
StatsSnapshoteither offline (--workdir) or via HTTP (--expvar). - Output fields include:
flush_queue_length,flush_wait_ms,flush_build_mscompaction_backlog,wal_active_segment,wal_segments_removedvlog_head,vlog_segments,vlog_pending_deletes,vlog_discard_queuetxns_active,txns_committed,txns_conflictsregion_total(plusregion_new,region_running,region_removing,region_tombstone,region_other)hot_keys(Top-N hits captured byhotring)
- Example:
nokv stats --workdir ./testdata/db --json | jq '.flush_queue_length'
nokv manifest
- Parses the manifest using
manifest.Manager.Version(). - Reports per-level file counts, smallest/largest keys, WAL checkpoint, and ValueLog metadata.
- Helpful for verifying flush/compaction results and ensuring manifest rewrites succeeded.
nokv vlog
- Lists vlog segments with status flags (
active,candidate_for_gc,deleted). - Shows head file/offset and pending GC actions.
- Use after running GC or recovery to confirm stale segments are purged.
Integration Tips
- Combine with
RECOVERY_TRACE_METRICS=1to cross-check logs: run tests, then inspect CLI output to ensure metrics match expectations. - In CI, capture JSON output and diff against golden files to detect regressions (see
cmd/nokv/main_test.go). - When comparing against RocksDB/Badger, treat
nokv manifest+nokv vlogas equivalents toldb manifest_dumpand Badger’sbadgerinspect vlogcommands.
For architecture context, see architecture.md and the module deep dives.
nokv regions– Dumps the manifest-backed Region catalog (ID/state/key range/peers). Supports--jsonfor automation and complements the Region metrics shown innokv stats.