grafana/loki

Interpretation of date range in Grafana UI vs query_range API is wrong

Open

#9,481 opened on 2023年5月18日

GitHub で見る
 (0 comments) (0 reactions) (0 assignees)Go (28,187 stars) (3,997 forks)batch import
component/apihelp wantedtype/bugtype/docs

説明

Describe the bug

I'm trying to perform analysis on our app using logged data. Because of the volume of data, I need to download the logs in chunks of 6 hours over a few months, using the query_range API. I am using the start and end parameters. Grafana appears to be doing something incorrect with these parameters.

The query_range api does not state whether the end date is an inclusive or exclusive bound. But based on what I'm seeing I think it's an exclusive bound, and Grafana is off by 1 second. I am unsure whether this is just an issue with the UI labels, or it actually sends the wrong parameters to the API when it makes the query.

This could cause analyses to be incorrect because the endpoints of the interval are double-counted or excluded accidentally.

To Reproduce

For example, in the Grafana UI, if I select an absolute time range, then click on the calendar box dropdown to select a single date, it will set the start and end date to 05-03-03 00:00:00 and 05-03-03 23:59:59. The query results state that 23 hours 59 min 59 secs are covered. This means that the last second of the day is not included in the query.

Expected behavior

The end timestamp should be 05-03-04 00:00:00 and the query range should be 24 hours instead of 23 hours 59 min 59 seconds.

Documentation for query_range needs to be clearer around how the ends of the range are handled.

コントリビューターガイド