Execute PLAN_CLI.md

This commit is contained in:
2026-03-14 20:30:23 +01:00
parent 76612c1cb8
commit b9ec67ec00
9 changed files with 1310 additions and 0 deletions

50
cmd/cli/main.go Normal file
View File

@@ -0,0 +1,50 @@
package main
import (
"fmt"
"os"
)
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
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 INT filter: exact HTTP status code
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 (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 "-h", "--help", "help":
fmt.Print(usage)
default:
fmt.Fprintf(os.Stderr, "unknown subcommand %q\n\n%s", os.Args[1], usage)
os.Exit(1)
}
}