From b3df9f5dfd70bb363c22cb952628bf78321bbea8 Mon Sep 17 00:00:00 2001 From: Mateusz Gozdek Date: Mon, 23 Aug 2021 13:04:03 +0200 Subject: [PATCH] cmd/logcli: add --follow flag as an alias for --tail (#4203) When using 'logcli query --tail', '--tail' behaves similar to the 'tail' command, which uses '--follow' flag, if you want to continuously follow the appended data to the file. I believe '--follow' flag is more natural for system administrators to use rather than '--tail' if one wants to "follow" the incoming logs, so this commit adds one, as an alias for '--tail'. Closes #3570 Signed-off-by: Mateusz Gozdek --- cmd/logcli/main.go | 3 ++- docs/sources/getting-started/logcli.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/logcli/main.go b/cmd/logcli/main.go index 391618a623..a60a36721c 100644 --- a/cmd/logcli/main.go +++ b/cmd/logcli/main.go @@ -73,6 +73,7 @@ If you are querying metrics and just want the most recent data point the "instant-query" command instead.`) rangeQuery = newQuery(false, queryCmd) tail = queryCmd.Flag("tail", "Tail the logs").Short('t').Default("false").Bool() + follow = queryCmd.Flag("follow", "Alias for --tail").Short('f').Default("false").Bool() delayFor = queryCmd.Flag("delay-for", "Delay in tailing by number of seconds to accumulate logs for re-ordering").Default("0").Int() instantQueryCmd = app.Command("instant-query", `Run an instant LogQL query. @@ -155,7 +156,7 @@ func main() { log.Fatalf("Unable to create log output: %s", err) } - if *tail { + if *tail || *follow { rangeQuery.TailQuery(time.Duration(*delayFor)*time.Second, queryClient, out) } else { rangeQuery.DoQuery(queryClient, out, *statistics) diff --git a/docs/sources/getting-started/logcli.md b/docs/sources/getting-started/logcli.md index 84e9f0ae38..5c61fbc4d0 100644 --- a/docs/sources/getting-started/logcli.md +++ b/docs/sources/getting-started/logcli.md @@ -316,6 +316,7 @@ Flags: from a given Loki configuration file. --colored-output Show output with colored labels -t, --tail Tail the logs + -f, --follow Alias for --tail --delay-for=0 Delay in tailing by number of seconds to accumulate logs for re-ordering