fix: alertmanager: validate labels and annotation names only, not values #441
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.
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area config
What this PR does / why we need it:
Only validate Prometheus Label names and Annotation names instead of validating values as well.
Internally, Alertmanager and Prometheus use the same data model to represent both labels and annotations,
and apply the same validation logic.
See official doc here : https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels, which mentions :
As a practical example, we encountered an issue because we use dashes in our label values,
such that this was rejected :
extralabels: "cloud:aws,region:eu-west-1,team:platform"
Special notes for your reviewer:
Hello, we are currently in the process of experimenting with this project for internal usage ;
it looks quite promising, great work 💪 😄
We encountered an issue when trying to use our standardized internal alert routing,
which should be fixed with these changes 🙏
It wasn't obvious to me where to add a test for such a bug fix,
I may have missed something but could not find config validation tests
so I didn't add one for this specific use case, I hope that's okay.