Skip to content

add Mattermost integration#4090

Merged
SuperQ merged 7 commits intoprometheus:mainfrom
UndeadDemidov:main
Nov 3, 2025
Merged

add Mattermost integration#4090
SuperQ merged 7 commits intoprometheus:mainfrom
UndeadDemidov:main

Conversation

@UndeadDemidov
Copy link
Contributor

@UndeadDemidov UndeadDemidov commented Nov 1, 2024

#1512
Here is Mattermost notifier. It supports Mattermost Webhooks according specs.
https://developers.mattermost.com/integrate/webhooks/incoming/

Tests and lints are passed.

@UndeadDemidov UndeadDemidov marked this pull request as ready for review November 1, 2024 10:07
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a rebase to pickup the slog migration changes.

Signed-off-by: UndeadDemidov <45305584+UndeadDemidov@users.noreply.github.com>
Signed-off-by: UndeadDemidov <45305584+UndeadDemidov@users.noreply.github.com>
Signed-off-by: UndeadDemidov <45305584+UndeadDemidov@users.noreply.github.com>
@UndeadDemidov
Copy link
Contributor Author

UndeadDemidov commented Nov 27, 2024

@SuperQ done with migrating to slog

@UndeadDemidov UndeadDemidov requested a review from SuperQ November 27, 2024 14:37
@vertrost
Copy link

vertrost commented Mar 5, 2025

Hi @SuperQ, it would be helpful, if we can use this feature.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit, otherwise LGTM.

@SuperQ
Copy link
Member

SuperQ commented Mar 6, 2025

👓 @grobinson-grafana

@grobinson-grafana
Copy link
Collaborator

👓 @grobinson-grafana

Taking a look! 👀

@fzakfeld
Copy link

fzakfeld commented Jun 5, 2025

Hey @grobinson-grafana - could this be merged or is there anything else blocking it? I would really appreciate this feature

@linusfr
Copy link

linusfr commented Jul 21, 2025

+1 on this being a great addition. Would love to utilize it :) Thanks for the implementation 🙇🏾

@larueli
Copy link

larueli commented Oct 13, 2025

Hello ! Thanks everyone for the great work you do and @UndeadDemidov for writing this PR ! I see that alertmanager 0.29.0 first release candidate is out. Is it possible to add this PR in this 0.29.0 release ? It seems like nothing is blocking (reviewer @SuperQ approved, all checks have passed, no conflicts with base branch). It would be really nice to be able to use alertmanager cleanly with Mattermost without hacks.

@filiprupic
Copy link

+1 waiting on this too

@venom13k
Copy link

venom13k commented Nov 1, 2025

+1

1 similar comment
@danilo-patrucco
Copy link

+1

Signed-off-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Ben Kochie <superq@gmail.com>
[ http_config: <http_config> | default = global.http_config ]
```

#### `<attachment_config>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related directly to this PR but I think in general we have potential for anchor link conflicts with generic names like this or <link_config> for PagerDuty, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I don't want to block this PR on this. But we should go through the docs for this kind of problem.

Co-authored-by: Siavash Safi <git@hosted.run>
Signed-off-by: Ben Kochie <superq@gmail.com>
Comment on lines +68 to +70
// request is the request for sending a Mattermost notification.
// https://developers.mattermost.com/integrate/webhooks/incoming/#parameters
type request struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: use payload instead of request:

Suggested change
// request is the request for sending a Mattermost notification.
// https://developers.mattermost.com/integrate/webhooks/incoming/#parameters
type request struct {
// payload is the payload sent to mattermost's incoming webhook API.
// https://developers.mattermost.com/integrate/webhooks/incoming/#parameters
type payload struct {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix this in a followup PR.

Comment on lines +109 to +112
if n.conf.WebhookURL != nil {
url = n.conf.WebhookURL.String()
} else {
content, err := os.ReadFile(n.conf.WebhookURLFile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not check yet, but do other notify integrations behave the same?
Basically configs overriding each other, if not then the behaviour should be documented and maybe log a warning message?

@SuperQ SuperQ merged commit 3b515b7 into prometheus:main Nov 3, 2025
7 checks passed
return false, err
}

resp, err := n.postJSONFunc(ctx, n.client, url, &buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including a timeout here might be a good idea. Example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there maybe a way to use a default/global timeout when notify.PostJSON/notfiy.PostText is used. eg. by setting a Deadline it the context does not already have a Deadline.

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.