feat: add extra-filter-labels param #522
Open
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.
Motivation and use cases
This param is mostly useful when using Sloth with a metric storage for multiple k8s clusters (like VictoriaMetrics).
Even if you would define a unique name for each SLO and provide a proper filter in each query, some of the generated rules would end up without the required filter and you would result in an error when executing the generated rules:
result contains metrics with the same labelset after applying rule labels
Assuming you define
--extra-filter-labels cluster=my-cluster-name
for Sloth operator,It allows for using the same SLO names on each cluster as
{{ .cluster }}
can be referenced in the user's query and also will be used as filter in the created recording rules, which users can't modify, fixing previously described problem. Thecluster
label will be also added to the resulting metrics in similar fasion to--extra-labels
, so it ensures that the resulting metrics can be differentiated.This fixes issues like #430 or can be helpful for #349