prometheus / alertmanager

Prometheus Alertmanager
https://prometheus.io
Apache License 2.0
6.59k stars 2.14k forks source link

Feature request: slack_configs.send_resolved a templatable field #4033

Open dwilliams782 opened 1 week ago

dwilliams782 commented 1 week ago

What did you do?

I'm trying to set up a receiver that can take a dynamic value for send_resolved, such as:

    ## Route alerts based on slack_channel label
      - name: global_slack_channel_label
        slack_configs:
          - api_url: <some-url>
            channel: '{{ printf \"#%s\" (index ((index .Alerts 0).Labels) \"slack_channel\") }}'
            send_resolved: {{ (index ((index .Alerts 0).Labels)) "send_resolved") | quote | default true | replace "\"" ""  }}

With this, we get a line 894: cannot unmarshal !!map into bool as Alertmanager requires this field to be boolean instead of a tmpl_string. There are various approaches to how this could be done so I'm not worried about this particular template working or not, but the send_resolved field does not allow templating as-is.

What did you expect to see?

I would like to be able to render true/false boolean based on a label in an alert. This would reduce the number of receivers required.

grobinson-grafana commented 1 week ago

I think, at least for me, it is hard to understand what the use case is for this feature. Making notification decisions based on individual alerts also doesn't fit well in the Alertmanager design, which is based around grouping related alerts together. It would also be very easy for someone to write an invalid template and accidentally break all their notifications without realizing it.