-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loki: Fix metric time splitting to split starting with the start time #80085
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matyax
approved these changes
Jan 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me. I currently see no reason to not make this change.
// to include the 08.02.2022, which we don't want. So we have to start from | ||
// the start, always ending at the last step before the actual end, or the total end. | ||
for (let chunkStartTime = alignedStartTime; chunkStartTime < endTime; chunkStartTime += alignedDuration) { | ||
const chunkEndTime = Math.min(chunkStartTime + alignedDuration - step, endTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes total sense.
zserge
pushed a commit
that referenced
this pull request
Jan 22, 2024
…#80085) * Loki: Fix metric time splitting to split starting with the start time * add test case to gdev-dashboard * fix splitting test
s0lesurviv0r
pushed a commit
to s0lesurviv0r/grafana
that referenced
this pull request
Feb 3, 2024
…grafana#80085) * Loki: Fix metric time splitting to split starting with the start time * add test case to gdev-dashboard * fix splitting test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this feature?
With Grafana's query splitting in Loki we previously expanded the timerange in such a way, that it might lead to querying more data than needed. E.g. a query with a
1d
step and1d
range over any specific duration would always lead to include an additional day.This PR fixes the adjustment of the end time range, and the calculation of metric splits. With this change, the smallest split will always be near the
end
time, i.e. it will also be the part that will be queried first. However, only with this we can ensure that we are not going out of bounds of the given duration.Special notes for your reviewer:
I added two panels to the query splitting gdev dashboard that should showcase the issue:
Without the change:
![image](https://private-user-images.githubusercontent.com/8092184/294525454-de3c7217-069c-46b8-af2e-350faead7962.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxODMyNDUsIm5iZiI6MTcyMjE4Mjk0NSwicGF0aCI6Ii84MDkyMTg0LzI5NDUyNTQ1NC1kZTNjNzIxNy0wNjljLTQ2YjgtYWYyZS0zNTBmYWVhZDc5NjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjhUMTYwOTA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZGE2MDg2ZWNjNjQxZTFmZmFhNzM3MWQ3NTVlNTIyMTJlZGZjNGEwM2QwMzYwY2QyMTU5MTIzZTUyNjYwNmU0ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.GBUjL6TOXHBjJeS2tsjPMP5iFQv4en0t_rKgiC-eBSE)
With the change:
![image](https://private-user-images.githubusercontent.com/8092184/294525868-206f0e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