-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add metric_patterns
options to filter all metric submission with a list of regexes
#11508
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Writing a single regular expression to match a collection of strings might not be the best UX for this. Would it make sense to let the user specify a list of glob patterns instead? (We could still use a compiled regular expression under the hood).
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.
- We should have both an inclusion and exclusion option
- They should be a list of patterns as @vickenty and @fanny-jiang suggested
- We should save like this
integrations-core/datadog_checks_base/datadog_checks/base/checks/openmetrics/v2/scraper.py
Lines 149 to 150 in 40a66fe
if exclude_metrics_patterns: self.exclude_metrics_pattern = re.compile('|'.join(exclude_metrics_patterns))
Ah thanks everyone- I'll update the field to be a list and also model the behavior of |
exclude_metrics_filters
and include_metrics_filters
options to filter all metric submission with a list of regexes
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.
^
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.
LGTM, just a small nit / suggestion.
if not isinstance(filters, list): | ||
raise ConfigurationError('Setting `{}` must be an array'.format(option_name)) | ||
|
||
metrics_pattern = None |
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.
metrics_pattern = None |
if metrics_patterns: | ||
metrics_pattern = re.compile('|'.join(metrics_patterns)) | ||
return metrics_pattern |
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.
Would it make sense to return the values directly, instead of going through a variable?
if metrics_patterns: | |
metrics_pattern = re.compile('|'.join(metrics_patterns)) | |
return metrics_pattern | |
if metrics_patterns: | |
return re.compile('|'.join(metrics_patterns)) | |
return None |
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.
Sure, I agree it's a little more readable this way
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.
🔥
Last thing, WDYTA naming them (ex|in)clude_metric_patterns
?
exclude_metrics_filters
and include_metrics_filters
options to filter all metric submission with a list of regexesmetric_filters
options to filter all metric submission with a list of regexes
Thanks, updated with the suggestion to have an overall param
|
metric_filters
options to filter all metric submission with a list of regexesmetric_patterns
options to filter all metric submission with a list of regexes
…list of regexes (#11508) * Add option for global metrics filter * Filter before context limiter * Compile regex and check for invalid regex * Add test for invalid regex * Add exclude and include filters * move regex logic down, add more tests * Remove space * Add more invalid tests * Refactor to helper functions, address comments, and add more tests * Add another test case * Add test case for include glob * Remove duplicate logic and further extract * Don't use metric_pattern veriable * Add overall metrics_filters param * Update message and tests * Rename to metric_patterns ddcf5dc
hi all. i'm struggling to find how can this be added to the prometheusScrape section in helm values.yaml |
What does this PR do?
Adds instance-level options to the base check to filter all metric submission with a regex. The main option is
metric_patterns
with two sub-options areexclude
andinclude
.Motivation
Allow users to have more control over what metrics are submitted for each integration
Additional Notes
exclude_labels
andinclude_labels
, whereexclude
takes precedence overinclude
exclude_metrics
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached