-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
api/rules: Add filtering on rule name/group/file #7560
Conversation
bdd78a9
to
66ba37e
Compare
This commits adds the option of filtering rules by rule name, rule group, or file. This brings the rule API closer in-line with the current Prometheus api. Signed-off-by: Jacob Baungard Hansen <jacobbaungard@redhat.com>
66ba37e
to
6ce555d
Compare
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.
Thanks for bringing it up to speed, some minor comments
} | ||
|
||
// filterRulesbyMatchers filters rules in a group according to given matcherSets. | ||
func filterRulesByMatchers(ruleGroups []*rulespb.RuleGroup, matcherSets [][]*labels.Matcher) []*rulespb.RuleGroup { |
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.
I think we also need to update this function now to better mimic prometheus/prometheus#10194?
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.
Yes, most likely. We also need exclude_alerts
to be fully aligned with the Prometheus API. Could we deal with those in separate PRs perhaps?
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
rnSet := queryFormToSet(ruleName) | ||
rgSet := queryFormToSet(ruleGroup) | ||
fSet := queryFormToSet(file) |
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.
Do you think just using slices.Contains
instead of set might be more memory intensive?
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.
The reason I did it like this, was simply because that's how the code looks like in Prometheus. I am not sure if there are significant performance benefits either way, although perhaps the code is a bit cleaner using slices.Contains
, so happy to change to that approach if you think it's best?
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.
Ah I see, fine if it mirrors prometheus then
This commits adds the option of filtering rules by rule name, rule group, or file. This brings the rule API closer in-line with the current Prometheus api. Signed-off-by: Jacob Baungard Hansen <jacobbaungard@redhat.com>
Changes
rule_name
,rule_group
orfile
. This brings the rules api closer in-line with Prometheus.Verification