Skip to content
Snippets Groups Projects
Commit 96223322 authored by Tom Wilkie's avatar Tom Wilkie
Browse files

Make queries take nanoseconds since epoch.


Signed-off-by: default avatarTom Wilkie <tom.wilkie@gmail.com>
parent 6f883b33
No related branches found
No related tags found
No related merge requests found
......@@ -89,8 +89,8 @@ There are 4 API endpoints:
For doing queries, accepts the following paramters in the query-string:
- `query`: a logQL query
- `limit`: max number of entries to return
- `start`: the start time for the query, as a Unix epoch (seconds since 1970)
- `end`: the end time for the query, as a Unix epoch (seconds since 1970)
- `start`: the start time for the query, as a nanosecond Unix epoch (nanoseconds since 1970)
- `end`: the end time for the query, as a nanosecond Unix epoch (nanoseconds since 1970)
- `direction`: `forward` or `backward`, useful when specifying a limit
- `regexp`: a regex to filter the returned results, will eventually be rolled into the query language
......
......@@ -28,18 +28,18 @@ func intParam(values url.Values, name string, def int) (int, error) {
return strconv.Atoi(value)
}
func unixTimeParam(values url.Values, name string, def time.Time) (time.Time, error) {
func unixNanoTimeParam(values url.Values, name string, def time.Time) (time.Time, error) {
value := values.Get(name)
if value == "" {
return def, nil
}
secs, err := strconv.ParseInt(value, 10, 64)
nanos, err := strconv.ParseInt(value, 10, 64)
if err != nil {
return time.Time{}, err
}
return time.Unix(secs, 0), nil
return time.Unix(0, nanos), nil
}
func directionParam(values url.Values, name string, def logproto.Direction) (logproto.Direction, error) {
......@@ -65,13 +65,13 @@ func (q *Querier) QueryHandler(w http.ResponseWriter, r *http.Request) {
}
now := time.Now()
start, err := unixTimeParam(params, "start", now.Add(-defaulSince))
start, err := unixNanoTimeParam(params, "start", now.Add(-defaulSince))
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
end, err := unixTimeParam(params, "end", now)
end, err := unixNanoTimeParam(params, "end", now)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment