Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd template function to get the alert name in the templates #2818
Comments
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
This is something that you'd be better off doing from the Alertmanager side, rather than duplicating that line in every single alert. |
This comment has been minimized.
This comment has been minimized.
|
@fabxc @brian-brazil : While true, that would still be nice to have. Prometheus rules are easier to manage by users than alertmanager config. |
This comment has been minimized.
This comment has been minimized.
|
The alertmanager config only needs to be setup once. |
This comment has been minimized.
This comment has been minimized.
|
Different teams have different playbooks stores and different templates depending on the destination. But sure, in another context doing it could be cleaner. Still, I think there is value into exposing $alertname or $labels.alertname here. |
This comment has been minimized.
This comment has been minimized.
|
It's not a label produced by the expression or added manually. The recommended way to do this is either via configuration management or notification templates. |
This comment has been minimized.
This comment has been minimized.
|
As I said, notifications templates in the routing tree are already not super easy to manage for us. Even less because while the prometheus isntances are handled by the users directly, the alertmanager instance is centralized. That being said, event if the recommended way is to do it in the alertmanager, I don't think it would hurt to expose more data to the alert templates. This could be as simple as:
We could also just set it to |
This comment has been minimized.
This comment has been minimized.
|
I'm against this, as it causes needless repetition in alerting rules. The alertmanager is where making your notifications look nice and useful belongs. |
This comment has been minimized.
This comment has been minimized.
|
As I said, doing that in the alertmanager doesn't seem to be as easy for us. Let's say that I have:
Regarding templates:
Now I need to effectively duplicate the logic to build the playbook url in all the templates that want to use it, instead of just being able to use $ .CommonAnnotations.documentation. Also, let's stay that I want to use something else that alertmanager, I'll also need to duplicate that. But maybe there is a smarter way to do that in the alertmanager that doesn't involve too much duplication ? (yeah, sure, it would be easier if there was a single http://playbook/$alertname destination, but that's currently not the case) |
This comment has been minimized.
This comment has been minimized.
You're proposing here to duplicate that logic in every single alert. Doing it in 4 places per team (it'd usually be 2-ish) seems simpler to me.
It'd be pretty rare that that would be the case across an organisation. Usually you'll only have consistency within a team. What I have seen is that the annotation would be an override, for the odd exception that crops up. |
This comment has been minimized.
This comment has been minimized.
Yep, because in our case we have more like ~4 severities per team (debug, ticket, urgent-ticket, page) times two (because, prod, preprod .. don't ask). |
This comment has been minimized.
This comment has been minimized.
|
I don't think we should be adding features that would be misused by the average user, merely because some users have more esoteric use cases. Especially as if you need different message for prod vs preprod, then the feature you're requesting doesn't help you - as you'd need a completely separate set of rules files for preprod for this to work in the way you suggest. |
brian-brazil
closed this
Jun 14, 2017
This comment has been minimized.
This comment has been minimized.
satterly
commented
Oct 28, 2018
|
Thought I should note here that the suggested fix by @brian-brazil to use notification templates in alertmanager is not supported for webhooks. Hopefully this will save others a lot of confusion and wasted time. |
iksaif commentedJun 7, 2017
•
edited
What did you do?
What did you expect to see?
What did you see instead? Under which circumstances?
Notes
Currently it looks like the template name contains the alertname, but I didn't find a way to access it.
An easy way to do that would be to add an alertname label and simply do $labels.alertname
If we can agree on a way to implement it, I'll be happy to do it.
cc: @Thib17