Skip to main content

๐Ÿ’ป CLI commands

The kwatch binary runs the monitor and ships a few commands for validating a configuration and exporting a recording. Most users only need kwatch lint. The commands run inside the kwatch pod, for example:

kubectl -n kwatch exec deploy/kwatch -- kwatch lint
CommandWhat it doesEdition
kwatchRun the monitorCommunity and Pro
kwatch versionPrint the version, commit and build dateCommunity and Pro
kwatch lintValidate the configurationCommunity and Pro
kwatch replay-exportExport the flight recordingPro

An unknown command exits with code 2 and does not start the monitor.

kwatch โ€” run the monitorโ€‹

Starts the monitor. It reads the config from the CONFIG_FILE environment variable (default /config/config.yaml).

kwatch version โ€” print the versionโ€‹

kwatch version
# version v1.2.0 (commit abc1234, built 2026-01-01T00:00:00Z)

kwatch version --json

--json prints the same data plus the active edition. The older --version flag still prints only the short version.

kwatch lint โ€” validate configurationโ€‹

Checks your config file without running the monitor.

kwatch lint
# config OK
FlagDescription
--strictReject unknown or misspelled config fields instead of warning
--checkAlso contact each provider that supports checks and verify its credentials
kwatch lint --check
# slack: OK
# email: FAIL โ€” could not connect to SMTP server

Lint exits 1 on an error and prints warnings, which are not fatal, for settings that work but may mislead. It also prints an info: line for each Pro setting your configuration contains while the edition is Community. Those settings are ignored, and the file stays valid for an upgrade. A real configuration check includes provider names and settings, ports, thresholds and silences. Lint requires at least one alert provider, although the monitor itself can run without one.

kwatch replay-export โ€” export the flight recording Proโ€‹

kwatch keeps a sanitized flight recording of what its sources observed (48 hours, capped at 64 MiB). replay-export writes a window of it as a log the scenario library can replay. Names are hashed pseudonyms, and log and event text is kept only as scrubbed text (log error lines, event and condition messages, with names, hosts, emails, images and credentials hidden), so the file is safe to share. With Helm, persistence.flightRecorderText: false drops all free text.

kubectl exec -n kwatch deploy/kwatch -- \
kwatch replay-export --since 2h --out /var/lib/kwatch/incident.jsonl
kubectl cp kwatch/<pod>:/var/lib/kwatch/incident.jsonl ./incident.jsonl
FlagDescription
--sinceStart of the window: a duration back (2h) or an RFC 3339 time. Required in practice
--untilEnd of the window, same format; default is now
--stateState file to read; default is the kwatch state file
--outFile to write. Required

The state file is locked while kwatch runs, so the command works on a copy next to the output file and needs free space for it. In Community the command exits with replay-export is a kwatch Pro feature.

Internal commands (used by the installer)โ€‹

The binary also has internal license subcommands that the kwatch.sh installer calls from its License / Pro menu. To manage a license, run the installer (bash <(curl -fsSL https://kwatch.dev/kwatch.sh)) and see License.

Environment variablesโ€‹

VariableDefaultDescription
CONFIG_FILE/config/config.yamlPath to the YAML config file
POD_NAMESPACEdetected from the podNamespace kwatch runs in
KWATCH_LICENSE_KEYemptyPro license key; wins over license.key
KWATCH_LOG_FORMATtextjson writes one JSON object per log line; wins over app.logFormatter
KWATCH_DATA_DIR/var/lib/kwatchDirectory of the state file
GOMEMLIMITbased on the resource limitSoft Go memory limit

The config file supports ${VAR} for non-sensitive strings. Credentials must use an absolute file reference backed by a mounted Secret:

alert:
slack:
webhook: "${file:/config/slack-webhook}"

Exit codesโ€‹

CodeMeaning
0Success
1Config error, lint failure, runtime error, or a Pro-only command in Community
2Unknown command or wrong arguments

When kwatch receives SIGTERM or SIGINT it shuts down gracefully: it marks readiness false, stops monitoring and delivery, waits for persistence writers, and exits with code 0.