Skip to content

Commit

Permalink
add support for RFC3339Nano in query timestamps (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena authored Jun 10, 2019
1 parent 6fac954 commit f939e42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ The Loki server has the following API endpoints (_Note:_ Authentication is out o

- `query`: a logQL query
- `limit`: max number of entries to return
- `start`: the start time for the query, as a nanosecond Unix epoch (nanoseconds since 1970). Default is always one hour ago.
- `end`: the end time for the query, as a nanosecond Unix epoch (nanoseconds since 1970). Default is current time.
- `start`: the start time for the query, as a nanosecond Unix epoch (nanoseconds since 1970) or as RFC3339Nano (eg: "2006-01-02T15:04:05.999999999Z07:00"). Default is always one hour ago.
- `end`: the end time for the query, as a nanosecond Unix epoch (nanoseconds since 1970) or as RFC3339Nano (eg: "2006-01-02T15:04:05.999999999Z07:00"). Default is current time.
- `direction`: `forward` or `backward`, useful when specifying a limit. Default is backward.
- `regexp`: a regex to filter the returned results, will eventually be rolled into the query language

Expand Down
3 changes: 3 additions & 0 deletions pkg/querier/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func unixNanoTimeParam(values url.Values, name string, def time.Time) (time.Time

nanos, err := strconv.ParseInt(value, 10, 64)
if err != nil {
if ts, err := time.Parse(time.RFC3339Nano, value); err == nil {
return ts, nil
}
return time.Time{}, err
}

Expand Down

0 comments on commit f939e42

Please sign in to comment.