Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logcli): query from absolute timestamp #736

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/logcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
regexpStr = queryCmd.Arg("regex", "").String()
limit = queryCmd.Flag("limit", "Limit on number of entries to print.").Default("30").Int()
since = queryCmd.Flag("since", "Lookback window.").Default("1h").Duration()
from = queryCmd.Flag("from", "Start looking for logs at this absolute time").String()
forward = queryCmd.Flag("forward", "Scan forwards through logs.").Default("false").Bool()
tail = queryCmd.Flag("tail", "Tail the logs").Short('t').Default("false").Bool()
delayFor = queryCmd.Flag("delay-for", "Delay in tailing by number of seconds to accumulate logs").Default("0").Int()
Expand Down
8 changes: 8 additions & 0 deletions cmd/logcli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ func doQuery() {

end := time.Now()
start := end.Add(-*since)
if *from != "" {
var err error
start, err = time.Parse(time.RFC3339, *from)
sh0rez marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
log.Fatalf("error parsing date '%s': %s", *from, err)
}
}

d := logproto.BACKWARD
if *forward {
d = logproto.FORWARD
Expand Down