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

Exclude vector queries from being counted in metric for rules with zero fetched series #6544

Merged

Conversation

zenador
Copy link
Contributor

@zenador zenador commented Nov 2, 2023

What this PR does

We have a counter metric that tracks rules with zero fetched series. This PR excludes queries that are just vector(number) from being counted in there, as those are not expected to fetch any series and are not an indication of late data that may affect the rules.

Which issue(s) this PR fixes or relates to

Follow up to #5925

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@zenador zenador requested review from a team as code owners November 2, 2023 15:44
@zenador zenador force-pushed the zenador/exclude-vector-ruler-zero-fetched-series branch 2 times, most recently from dcc414d to 6f0f8db Compare November 2, 2023 16:13
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

i'd imagine there are other queries that fetch 0 series. Any constant expression or any of the promql functions that don't take any args (week() day_of_week() time()). Do we want to account for them too?

One way to do that is to parse the promql query and find if it has any vector selector. This an example of doing this in the query-frontend

if expr, err := parser.ParseExpr(req.GetQuery()); err == nil {
for _, selectors := range parser.ExtractSelectors(expr) {
for _, matcher := range selectors {
if matcher.Type != labels.MatchRegexp && matcher.Type != labels.MatchNotRegexp {
continue
}
s.regexpMatcherCount.Inc()
if matcher.IsRegexOptimized() {
s.regexpMatcherOptimizedCount.Inc()
}
}
}
}

@zenador zenador force-pushed the zenador/exclude-vector-ruler-zero-fetched-series branch from 6f0f8db to 1200508 Compare November 23, 2023 15:49
@zenador
Copy link
Contributor Author

zenador commented Nov 23, 2023

Thanks, good suggestion!

@leizor
Copy link
Contributor

leizor commented Nov 28, 2023

The CHANGELOG has just been cut to prepare for the next Mimir release. Please rebase main and eventually move the CHANGELOG entry added / updated in this PR to the top of the CHANGELOG document. Thanks!

@zenador zenador force-pushed the zenador/exclude-vector-ruler-zero-fetched-series branch from 66984b0 to a703bab Compare November 29, 2023 08:44
@zenador zenador force-pushed the zenador/exclude-vector-ruler-zero-fetched-series branch from a703bab to 213866c Compare November 30, 2023 10:56
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@dimitarvdimitrov dimitarvdimitrov merged commit 7f92003 into main Nov 30, 2023
@dimitarvdimitrov dimitarvdimitrov deleted the zenador/exclude-vector-ruler-zero-fetched-series branch November 30, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants