Skip to content

mattermost: flatten attachments into top-level config, keep BC#5009

Open
madest92 wants to merge 4 commits intoprometheus:mainfrom
madest92:mm-message-template
Open

mattermost: flatten attachments into top-level config, keep BC#5009
madest92 wants to merge 4 commits intoprometheus:mainfrom
madest92:mm-message-template

Conversation

@madest92
Copy link

@madest92 madest92 commented Feb 12, 2026

This PR refactors the Mattermost receiver configuration by flattening the attachment structure(like slack_configs).

Previously, message formatting required configuring fields inside attachments[0].
Now, commonly used fields such as title, title_link, color, and text are promoted to the top level of mattermost_configs.

Additionally, more default templates are provided to reduce the need for repetitive manual configuration.

Example with default template:

receivers:
- name: 'mm'
  mattermost_configs:
  - send_resolved: false
image

Breaking change

This change modifies the configuration schema of mattermost_configs.

Old configuration:

mattermost_configs:
  - text: ''
    attachments:
      - color: '{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}'
        title: '{{ .CommonAnnotations.summary }}'
        title_link: '{{ template "__alertmanagerURL" . }}'
        text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'

New configuration:

mattermost_configs:
  - title: '{{ .CommonAnnotations.summary }}'
    title_link: '{{ template "__alertmanagerURL" . }}'
    color: '{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}'
    text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'

Users must update existing configurations accordingly.

Signed-off-by: Kliachin Aleksei <madest92@gmail.com>
@madest92
Copy link
Author

@TheMeier hi
We discussed this here

@TheMeier
Copy link
Contributor

Why is asset/assets_vfsdata.go here?

@TheMeier
Copy link
Contributor

Users must update existing configurations accordingly.

That does not sound good to me

@madest92
Copy link
Author

madest92 commented Feb 12, 2026

Why is asset/assets_vfsdata.go here?

I updated the templates. Without this, alertmanager would not see new templates.

@madest92
Copy link
Author

madest92 commented Feb 12, 2026

That does not sound good to me

I know. Me too. But the current configuration isn't convenient via attachments. I still use slack_configs.

global:
  slack_api_url: '<mattermost_webhook>'

receivers:
  - name: 'critical'
    slack_configs:
    - send_resolved: true
      title: '{{...}}'
      text: '{{...}}'

Mattermost was introduced not long ago, so I don't think it's a big problem.

@siavashs
Copy link
Contributor

That does not sound good to me

I know. Me too. But the current configuration isn't convenient via attachments. I still use slack_configs.
...
Mattermost was introduced not long ago, so I don't think it's a big problem.

That is not a good excuse, we need to make changes backwards compatible.
The best approach is to deprecate the old fields and introduce the new ones.
Eventually we can remove the deprecated fields in a future release where we announce the breaking change.

@madest92
Copy link
Author

That is not a good excuse, we need to make changes backwards compatible.

Agreed. I'll make it backwards compatible.

@madest92 madest92 marked this pull request as draft February 14, 2026 02:17
Signed-off-by: Kliachin Aleksei <madest92@gmail.com>
@madest92
Copy link
Author

@siavashs

I added backward compatibility

  1. Old behavior when user uses attachment
image
  1. New behavior without using attachment. Default templates are already in use
image

@madest92 madest92 marked this pull request as ready for review February 14, 2026 14:44
@madest92 madest92 changed the title mattermost: flatten attachment config and promote fields to top level mattermost: flatten attachments into top-level config, keep BC Feb 14, 2026
Signed-off-by: Kliachin Aleksei <madest92@gmail.com>
@madest92 madest92 force-pushed the mm-message-template branch from 7ce9300 to a14e95b Compare February 24, 2026 01:01
@madest92 madest92 force-pushed the mm-message-template branch from cf5abd4 to 4bfff01 Compare February 27, 2026 02:46
@madest92
Copy link
Author

@TheMeier @siavashs hi guys.

Can you please look at the merge again?

Anything else needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants