Skip to content

add Mattermost integration - #4090

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

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

Conversation

@UndeadDemidov

@UndeadDemidov UndeadDemidov commented Nov 1, 2024

Copy link
Copy Markdown
Contributor

#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

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

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

UndeadDemidov commented Nov 27, 2024

Copy link
Copy Markdown
Contributor Author

@SuperQ done with migrating to slog

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

vertrost commented Mar 5, 2025

Copy link
Copy Markdown

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

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nit, otherwise LGTM.

Comment thread notify/mattermost/mattermost.go Outdated
Comment thread notify/mattermost/mattermost_test.go Outdated
@SuperQ

SuperQ commented Mar 6, 2025

Copy link
Copy Markdown
Member
@grobinson-grafana

Copy link
Copy Markdown
Collaborator

👓 @grobinson-grafana

Taking a look! 👀

@fzakfeld

fzakfeld commented Jun 5, 2025

Copy link
Copy Markdown

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

@linusfr

linusfr commented Jul 21, 2025

Copy link
Copy Markdown

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

@larueli

larueli commented Oct 13, 2025

Copy link
Copy Markdown

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
Copy Markdown

+1 waiting on this too

@venom13k

venom13k commented Nov 1, 2025

Copy link
Copy Markdown

+1

1 similar comment
@danilo-patrucco

Copy link
Copy Markdown

+1

Comment thread notify/mattermost/mattermost_test.go Outdated
Signed-off-by: Ben Kochie <superq@gmail.com>
Comment thread notify/mattermost/mattermost_test.go Outdated
Signed-off-by: Ben Kochie <superq@gmail.com>
Comment thread docs/configuration.md
[ http_config: <http_config> | default = global.http_config ]
```

#### `<attachment_config>`

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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