github mr-karan/logchef cli-v0.1.6
Logchef CLI v0.1.6

latest release: v1.6.1
one month ago

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-queries command — List saved queries and run one by name, numeric ID, or pasted explorer URL, with --limit, --var, and --output overrides.
  • find command — 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 --debug for per-source diagnostics.
  • tail command — Follow matching LogChefQL rows with bounded polling and text, jsonl, or msg output. Dedup is stable across column-order changes between polls; when a poll returns at --limit a one-shot warning hints to raise --limit or shrink --interval.
  • whoami command — Print the authenticated user and accessible teams.
  • auth current subcommand — 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 flagslogchef sql now accepts --since, --from, and --to. The predicate is injected before the first top-level GROUP 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-sql alias on sql--explain is now an alias of --show-sql on both query and sql. Both print Generated SQL: <sql> to stderr and continue executing.
  • --dry-run on query and sql — Prints the resolved SQL to stdout (no prefix, pipes cleanly) and exits without keeping results. query --dry-run still calls the server once for LogChefQL translation; sql --dry-run is fully offline.
  • --output msg modequery, sql, collections, and saved-queries can print message text only, one row per line.
  • --output json-flat mode — Hoist JSON-shaped msg fields to top-level JSON rows.
  • LOGCHEF_DEFAULT_TEAM / LOGCHEF_DEFAULT_SOURCE env vars — Supply stateless defaults when --team / --source are omitted. Precedence: flag > env > saved config.
  • Schema column descriptionsschema --output text shows an extra DESCRIPTION column when the source's ClickHouse columns have comments; schema --output json includes 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 ... | jq and ... > file produce clean output without --no-highlight. The flag still works as an explicit override.

Full Changelog: cli-v0.1.5...cli-v0.1.6

Don't miss a new logchef release

NewReleases is sending notifications on new releases.