Skip to content
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

Don't return incorrect position information from annotations generated by sharded query legs #9536

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

charleskorn
Copy link
Contributor

@charleskorn charleskorn commented Oct 7, 2024

What this PR does

This PR fixes an issue where annotations could be returned to a user with incorrect position information if the query is sharded and the sharded legs generate annotations.

For example, running the query avg(rate(up[1m])) can produce two annotations:

  • PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: "up" (1:10)
  • PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: "up" (1:12)

...but up appears at position 10 on line 1, so the second annotation at position 12 is misleading or confusing. It comes about because avg(...) is rewritten as sum(...) / count(...) for sharding and the second annotation is generated by queriers for the sharded count(rate(up[1m])) legs.

Another example: running the query ceil(sum(rate(up[1m]))) returns PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: "up" (1:10) (because sum(rate(up[1m])) is what is run in queriers), but up appears at position 15.

We already remove position information for annotations generated by the parent query (ie. the one run in query-frontends to combine the results of the sharded legs), so this PR does the same for annotations from sharded legs.

Which issue(s) this PR fixes or relates to

Related to #9138

Checklist

  • Tests updated.
  • [n/a] Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [n/a] about-versioning.md updated with experimental features.

@charleskorn charleskorn force-pushed the charleskorn/sharding-annotations branch from 7f4a867 to 69c66a3 Compare October 7, 2024 06:03
@charleskorn charleskorn marked this pull request as ready for review October 7, 2024 06:09
@charleskorn charleskorn requested a review from a team as a code owner October 7, 2024 06:09
Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Have you considered how difficult it would be to re-write/re-calculate the positions post-shard? Either way, better to not have them than have incorrect ones for now.

@charleskorn
Copy link
Contributor Author

LGTM. Have you considered how difficult it would be to re-write/re-calculate the positions post-shard? Either way, better to not have them than have incorrect ones for now.

I started looking into it, and it would be quite involved - certainly not impossible, but likely not worth the effort for most queries where the thing each annotation is referring to is usually clear.

@charleskorn charleskorn merged commit cabc3ee into main Oct 8, 2024
29 checks passed
@charleskorn charleskorn deleted the charleskorn/sharding-annotations branch October 8, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants