Build and release tooling:
- Makefile with help as default; targets: build/build-amd64/build-arm64,
test, lint, proto, pkg-deb, docker, docker-push, clean, plus
install-deps (+ three sub-targets for apt / Go toolchain / Go tools).
- internal/version package; -ldflags -X injects Version/Commit/Date into
every binary. -version flag on all four binaries (nginx-logtail version
for the CLI).
- Dockerfile takes VERSION/COMMIT/DATE build-args and forwards them.
- .deb output lands in build/; .gitignore ignores /build/.
Debian package:
- debian/build-deb.sh packages all four static binaries into a single
nginx-logtail_<ver>_<arch>.deb using dpkg-deb.
- Binary layout: /usr/sbin/nginx-logtail-{collector,aggregator,frontend}
and /usr/bin/nginx-logtail.
- nginx-logtail(8) manpage.
- Three systemd units (collector, aggregator, frontend) shipped under
/lib/systemd/system/. Installed but never enabled or started — the
operator opts in per host.
- Collector runs as _logtail:www-data (log access); aggregator and
frontend as _logtail:_logtail. postinst creates the system user/group
idempotently.
- Single shared env file /etc/default/nginx-logtail rendered from a
template at first install with %HOSTNAME% substituted. Sensible
defaults for every COLLECTOR_*, AGGREGATOR_*, FRONTEND_* variable;
plus COLLECTOR_ARGS / AGGREGATOR_ARGS / FRONTEND_ARGS escape hatches
appended to ExecStart. Not a dpkg conffile: operator edits survive
upgrades and dpkg --purge removes it.
Versioned UDP wire format:
- ParseUDPLine dispatches on a leading "v<N>\t" tag; v1 routes to the
existing 12-field parser. Unknown/missing versions fail closed so
future v2 parsers can land before emitters are upgraded.
- Tests updated; design.md FR-2.2 rewritten to make the version tag
normative.
Docs:
- README.md gains a Quick Start (Debian / Docker Compose / from source).
- user-guide.md rewritten around Installation and Configuration: full
env-var table, UDP-only default explained, precise file/UDP log_format
layouts, note that operators can emit "0" for unknown \$is_tor / \$asn.
- Drilldown cycle, frontend filter table, and CLI --group-by list all
include source_tag. UDP counters documented in the Prometheus section.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.ipng.ch/ipng/nginx-logtail/internal/version"
|
|
)
|
|
|
|
const usage = `logtail-cli — debug shell for nginx-logtail collectors and aggregators
|
|
|
|
Usage:
|
|
logtail-cli topn [flags] ranked label → count list
|
|
logtail-cli trend [flags] per-minute time series
|
|
logtail-cli stream [flags] live snapshot feed
|
|
logtail-cli targets [flags] list targets known to the queried endpoint
|
|
|
|
Subcommand flags (all subcommands):
|
|
--target host:port[,host:port,...] endpoints to query (default: localhost:9090)
|
|
--json emit newline-delimited JSON
|
|
--website STRING filter: exact website match
|
|
--prefix STRING filter: exact client-prefix match
|
|
--uri STRING filter: exact request URI match
|
|
--status EXPR filter: HTTP status expression (200, !=200, >=400, <500, …)
|
|
--website-re REGEX filter: RE2 regex against website
|
|
--uri-re REGEX filter: RE2 regex against request URI
|
|
--is-tor EXPR filter: TOR (1/!=0 = only, 0/!=1 = none)
|
|
--asn EXPR filter: ASN expression (12345, !=65000, …)
|
|
--source-tag STRING filter: exact ipng_source_tag match
|
|
|
|
topn flags:
|
|
--n INT number of entries (default 10)
|
|
--window STR 1m 5m 15m 60m 6h 24h (default 5m)
|
|
--group-by STR website prefix uri status asn source_tag (default website)
|
|
|
|
trend flags:
|
|
--window STR 1m 5m 15m 60m 6h 24h (default 5m)
|
|
`
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
fmt.Fprint(os.Stderr, usage)
|
|
os.Exit(1)
|
|
}
|
|
switch os.Args[1] {
|
|
case "topn":
|
|
runTopN(os.Args[2:])
|
|
case "trend":
|
|
runTrend(os.Args[2:])
|
|
case "stream":
|
|
runStream(os.Args[2:])
|
|
case "targets":
|
|
runTargets(os.Args[2:])
|
|
case "-h", "--help", "help":
|
|
fmt.Print(usage)
|
|
case "-version", "--version", "version":
|
|
fmt.Printf("logtail-cli %s\n", version.String())
|
|
default:
|
|
fmt.Fprintf(os.Stderr, "unknown subcommand %q\n\n%s", os.Args[1], usage)
|
|
os.Exit(1)
|
|
}
|
|
}
|