Split rule group "node" into "node" (only alerts) and "node-records" (only records) #1175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After upgrade I am unable to set different labels for record rules and alert rules
We write metrics from multiple clusters into federated vm-stack. It has record VMRules from vm-stack, which use scraped metrics as an input and write them back with defaultRules labels, which overwrite cluster label from scraped metrics. So multiple input clusters end up in metrics which are recorded with labels from target cluster, making it impossible to use such setup (used to work before ae208d5).
There is a solution through rule groups, so I made this not very pretty, but working values.yaml:
(Not that "labels: null" cannot be used here, as some rules have their own labels in upstream and they must survive.)
But I cannot make same config for rule group "node".
There are three rule groups in upstream:
After sync_rules.py those groups get into separate files in files/rules/generated without renames.
Next step is VMRule generation in templates/rules/rule.yaml, which uses "sanitized group name":
This sanitized name is generated in templates/_helpers.tpl:
So, here words "exporter" and "rules" are dropped from the group name and three groups node-exporter/node-exporter.rules/node.rules end up in combined group "node", which makes it impossible to set labels for alert while not setting them for records.
There are multiple solutions possible:
In this PR I offer an implementation of the solution number 3, but I would be happy with any working solution, which you consider more appropriate.
P.S. As a side note I want to point out that same problem encountered in kube-prometheus-stack helm chart prometheus-community/helm-charts#3396, which could be used as a proof of popularity of such setup with multiple clusters and separate labels.