Drop chcat/chtail/chgrep symlink entrypoints; ship chlog subcommands only
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

The RPM's /usr/bin/chcat conflicts with SELinux's
policycoreutils-python-utils on Fedora. Per Ben: remove the symlink
entrypoints entirely and ship only the chlog binary with cat/tail/grep
subcommands.

- Remove chcat/chtail/chgrep symlinks and their completions from
  nfpm.yaml, build-rpm.sh and the Makefile
- Remove the argv[0] dispatch in main.go; subcommands are unchanged
- Update the completion test to cover chlog only
- Update README usage to chlog cat|tail|grep
This commit is contained in:
2026-08-23 21:39:17 +10:00
parent dfd4efd782
commit ee2f270abc
8 changed files with 60 additions and 145 deletions
+20 -16
View File
@@ -1,20 +1,24 @@
# clickhouse-tools
CLI tools for the ClickHouse log store (`logs.raw`): one binary, `chlog`, with
three entrypoints installed as symlinks:
three subcommands:
| Command | Also as | Does |
|----------|---------------|------|
| `chcat` | `chlog cat` | Print logs oldest-first over a bounded time range |
| `chtail` | `chlog tail` | Follow logs live (2s poll, overlap + dedupe so nothing is lost or repeated) |
| `chgrep` | `chlog grep` | Search log messages (substring, `-i`, `--regex`) |
| Command | Does |
|--------------|------|
| `chlog cat` | Print logs oldest-first over a bounded time range |
| `chlog tail` | Follow logs live (2s poll, overlap + dedupe so nothing is lost or repeated) |
| `chlog grep` | Search log messages (substring, `-i`, `--regex`) |
(Earlier releases also shipped `chcat`/`chtail`/`chgrep` symlinks; they were
dropped because `/usr/bin/chcat` conflicts with SELinux's
`policycoreutils-python-utils` package.)
## Why time bounds everywhere
`logs.raw` has no text index and holds ~281M rows/day (3-day TTL). An unbounded
message scan takes ~1 minute and the server kills queries at 120s. Every query
these tools issue is therefore time-bounded — the default range is the last
hour (`--since 1h`) — and `chgrep` refuses a search wider than 6h with no
hour (`--since 1h`) — and `chlog grep` refuses a search wider than 6h with no
`--namespace`/`--host`/`--app` filter unless you pass `--force`.
All user input travels as ClickHouse HTTP `{name:Type}` parameters; nothing is
@@ -23,12 +27,12 @@ ever interpolated into SQL text.
## Usage
```sh
chcat -n logging --since 30m
chcat --host web01 --since 2h --until 1h --format logfmt
chtail -n media --app jellyfin
chgrep -n kube-system -i "connection refused" --since 4h
chgrep --app vector --regex 'timed? ?out' --since 1d
chgrep --fields req_id=42 -n api "payment"
chlog cat -n logging --since 30m
chlog cat --host web01 --since 2h --until 1h --format logfmt
chlog tail -n media --app jellyfin
chlog grep -n kube-system -i "connection refused" --since 4h
chlog grep --app vector --regex 'timed? ?out' --since 1d
chlog grep --fields req_id=42 -n api "payment"
```
### Common flags
@@ -41,7 +45,7 @@ chgrep --fields req_id=42 -n api "payment"
- `--format text|json|logfmt` — text is `ts ns/pod msg` (host for vm rows),
colored only on a TTY (`NO_COLOR` respected)
### chgrep extras
### chlog grep extras
- pattern is a substring by default; `-i` case-insensitive; `--regex` RE2 (`match()`)
- `--fields key=value` (repeatable) filters the structured `fields` map
@@ -58,8 +62,8 @@ chgrep --fields req_id=42 -n api "payment"
## Build and release
```sh
make build # dist/chlog + symlinks
make build # dist/chlog
make test # go test -race ./...
make rpm # nfpm RPM with binary, symlinks, bash/zsh/fish completions
make rpm # nfpm RPM with binary + bash/zsh/fish completions
make patch # tag + push next vX.Y.Z → CI releases RPM to artifactapi rpm-internal
```