From a0ac6c692ecd6dfd3d5071d85faad287d3cb61bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Tue, 3 May 2022 17:30:15 +0200 Subject: [PATCH] loki: backend: use millisecond-timestamps (#48630) --- pkg/tsdb/loki/api.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/tsdb/loki/api.go b/pkg/tsdb/loki/api.go index 92ffb697049..08e3b1eb8c5 100644 --- a/pkg/tsdb/loki/api.go +++ b/pkg/tsdb/loki/api.go @@ -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: