loki: backend: use millisecond-timestamps (#48630)

This commit is contained in:
Gábor Farkas
2022-05-03 17:30:15 +02:00
committed by GitHub
parent be96c872d1
commit a0ac6c692e
+7 -1
View File
@@ -51,7 +51,13 @@ func makeRequest(ctx context.Context, lokiDsUrl string, query lokiQuery) (*http.
// is ignored, so it would be nicer to not send it in such cases,
// but we cannot detect that situation, so we always send it.
// it should not break anything.
qs.Set("step", query.Step.String())
// NOTE2: we do this at millisecond precision for two reasons:
// a. Loki cannot do steps with better precision anyway,
// so the microsecond & nanosecond part can be ignored.
// b. having it always be number+'ms' makes it more robust and
// precise, as Loki does not support step with float number
// and time-specifier, like "1.5s"
qs.Set("step", fmt.Sprintf("%dms", query.Step.Milliseconds()))
lokiUrl.Path = "/loki/api/v1/query_range"
}
case QueryTypeInstant: