prometheus / prometheus/alertmanager

Feature request: slack_configs.send_resolved a templatable field

Open
#4,033 17 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement stale
Dominant language
Go
Stars
8.6k
Forks
2.5k
Avg merge
2d 6h
Merged PRs (30d)
61

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Alertmanager's configuration handling for slack_configs.send_resolved and trace how this field is parsed and validated as a boolean. Review the templating behavior described in the issue and any related configuration tests, then establish behavior that accepts dynamically rendered true or false values while preserving static booleans.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.