Skip to content

Commit

Permalink
cmd/logcli: add --follow flag as an alias for --tail (#4203)
Browse files Browse the repository at this point in the history
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 <mgozdekof@gmail.com>
  • Loading branch information
invidian authored Aug 23, 2021
1 parent e25587b commit b3df9f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/logcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/sources/getting-started/logcli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3df9f5

Please sign in to comment.