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

Track number of optimised regexp label matchers #4813

Conversation

dhanusaputra
Copy link
Contributor

@dhanusaputra dhanusaputra commented Apr 21, 2023

What this PR does

  • add regexpMatcherCount and regexpMatcherOptimizedCount metrics
  • update longestRegexpMatcherBytes so it can return more data

Which issue(s) this PR fixes or relates to

Fixes #4638

Checklist

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

@CLAassistant
Copy link

CLAassistant commented Apr 21, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

Great work, thanks! Just one small suggestion.

CHANGELOG.md Outdated
@@ -10,6 +10,7 @@
* [ENHANCEMENT] Go: update to 1.20.3. #4773
* [ENHANCEMENT] Store-gateway: reduce memory usage in some LabelValues calls. #4789
* [ENHANCEMENT] Store-gateway: add a `stage` label to the metric `cortex_bucket_store_series_data_touched`. This label now applies to `data_type="chunks"` and `data_type="series"`. The `stage` label has 2 values: `processed` - the number of series that parsed - and `returned` - the number of series selected from the processed bytes to satisfy the query. #4797
* [ENHANCEMENT] Query-frontend: track number of optimised regexp label matchers. #4813
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* [ENHANCEMENT] Query-frontend: track number of optimised regexp label matchers. #4813
* [ENHANCEMENT] Query-frontend: Add `cortex_frontend_regexp_matcher_count` and `cortex_frontend_regexp_matcher_optimized_count` metrics to track optimization of regular expression label matchers. #4813

Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! My only comment is that that way it's implemented means it gets tracked only for tenants with query sharding enabled. I think we should track for every query. For this reason, I think a better place where to place this logic is pkg/frontend/querymiddleware/stats.go. You will need to parse the query there again (in a follow up PR we can do a refactoring to parse the query once and pass around the parsed query along with the Request).

@dhanusaputra dhanusaputra force-pushed the track-number-of-optimised-regexp-label-matchers branch from a773221 to 48dca36 Compare April 28, 2023 14:18
@dhanusaputra
Copy link
Contributor Author

test:

image

@dhanusaputra dhanusaputra marked this pull request as ready for review April 28, 2023 14:29
@dhanusaputra dhanusaputra requested a review from a team as a code owner April 28, 2023 14:29
@dhanusaputra dhanusaputra force-pushed the track-number-of-optimised-regexp-label-matchers branch from cfdaa8d to 1311a66 Compare May 16, 2023 12:36
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@pracucci pracucci enabled auto-merge (squash) May 29, 2023 08:25
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci
Copy link
Collaborator

I pushed a commit 5b6e6f9 to ignore any parsing error in queryStatsMiddleware, to let this PR moving forward. I plan to refactoring the query parsing anyway, doing it only once in the query-frontend, so that will be addressed in a follow up PR.

@pracucci
Copy link
Collaborator

@dhanusaputra could you sign the CLA (see message above)? Otherwise we can't merge this PR.

@pracucci pracucci merged commit 3543b63 into grafana:main May 29, 2023
21 checks passed
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.

Track number of optimised regexp label matchers
4 participants