LogChef CLI v0.1.6
Major CLI release. Four new subcommands, full time-range injection on raw SQL, agent-friendly output formats, a symmetric --explain / --dry-run split across query and sql, and TTY-aware highlighting so pipes don't need --no-highlight. Requires Logchef server v1.6.1+ for the saved-queries resolve endpoint and ClickHouse column descriptions.
Added
saved-queriescommand — List saved queries and run one by name, numeric ID, or pasted explorer URL, with--limit,--var, and--outputoverrides.findcommand — Discover sources with recent matches for a service, job, host, or message pattern. For each matched source, fires a small per-column sample query: label-shaped columns (service/host/job_name) get the top 3 values with counts; free-form text columns (msg) get a single truncated sample row. Suppress with--no-samples. Per-source query timeout defaults to 30s. Sources that error out (permissions, schema fetch, query failure) are skipped and counted; rerun with--debugfor per-source diagnostics.tailcommand — Follow matching LogChefQL rows with bounded polling andtext,jsonl, ormsgoutput. Dedup is stable across column-order changes between polls; when a poll returns at--limita one-shot warning hints to raise--limitor shrink--interval.whoamicommand — Print the authenticated user and accessible teams.auth currentsubcommand — Offline command that prints the active context, server URL, and token source (env vs config) without hitting the network. When the token comes from saved config, also prints the expiry timestamp.- SQL time flags —
logchef sqlnow accepts--since,--from, and--to. The predicate is injected before the first top-levelGROUP BY/ORDER BY/LIMIT/HAVING/SETTINGS/FORMAT; the scanner skips string literals, quoted identifiers, comments, and parenthesized subqueries. Use__START__/__END__placeholders for full control (e.g. CTEs). --explain/--show-sqlalias onsql—--explainis now an alias of--show-sqlon bothqueryandsql. Both printGenerated SQL: <sql>to stderr and continue executing.--dry-runonqueryandsql— Prints the resolved SQL to stdout (no prefix, pipes cleanly) and exits without keeping results.query --dry-runstill calls the server once for LogChefQL translation;sql --dry-runis fully offline.--output msgmode —query,sql,collections, andsaved-queriescan print message text only, one row per line.--output json-flatmode — Hoist JSON-shapedmsgfields to top-level JSON rows.LOGCHEF_DEFAULT_TEAM/LOGCHEF_DEFAULT_SOURCEenv vars — Supply stateless defaults when--team/--sourceare omitted. Precedence: flag > env > saved config.- Schema column descriptions —
schema --output textshows an extra DESCRIPTION column when the source's ClickHouse columns have comments;schema --output jsonincludes them inline.
Changed
- Auto-disables ANSI highlighting on non-TTY output — All five subcommands (
query,sql,collections,saved-queries,tail) skip highlighting when stdout is piped, so... | jqand... > fileproduce clean output without--no-highlight. The flag still works as an explicit override.
Full Changelog: cli-v0.1.5...cli-v0.1.6