Skip to content

notify/discord: Create Discord integration#2948

Merged
metalmatze merged 1 commit into
prometheus:mainfrom
metalmatze:discord
Oct 25, 2022
Merged

notify/discord: Create Discord integration#2948
metalmatze merged 1 commit into
prometheus:mainfrom
metalmatze:discord

Conversation

@metalmatze

@metalmatze metalmatze commented Jun 17, 2022

Copy link
Copy Markdown
Member

For our https://demo.parca.dev instance we want to alert to be send to Discord.
Therefore I've worked on integrating Discord directly into Alertmanager.

The integration doesn't need any external dependencies and uses JSON to send the payloads to Discord via webhooks to a specific channel.

This integration is already in use for our alerting for a week now and has been working great so far.

@metalmatze metalmatze force-pushed the discord branch 2 times, most recently from 9787bd9 to d52e1ce Compare June 17, 2022 11:56
@metalmatze

Copy link
Copy Markdown
Member Author

This integration was heavily inspired by the work done in https://github.com/benjojo/alertmanager-discord
Thanks for your hard work @benjojo.

@benjojo

benjojo commented Jun 17, 2022

Copy link
Copy Markdown

Ah ha! Sorry for not getting around to the original, but thanks for doing this anyway!

@metalmatze

Copy link
Copy Markdown
Member Author

Ah ha! Sorry for not getting around to the original, but thanks for doing this anyway!

No worries. This is how it works in open source, I guess. ☺️

Comment thread notify/discord/discord.go Outdated

@gotjosh gotjosh 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.

LGTM - I think the template can look better (e.g. better formatting when having multiple alerts and adding a link to the silences) but let's see what kind of feedback we get after people start using it.

I do have a request for the Avatar URL and optional override of username - can you please take a look at my comment?

Screenshot 2022-06-27 at 14 16 47

Once, we finish the discussion around avatar and username I'll be happy to approve and merge.

Comment thread config/config.go Outdated
Comment thread config/notifiers.go Outdated
Comment thread config/notifiers.go Outdated

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.

I know this might be a bit more work, but I'd love it if we can add two new options:

  • Avatar URL avatar_url
  • Username username

(they belong on the main webhook object and not the embedded, see: https://discord.com/developers/docs/resources/webhook#execute-webhook)

For the sake of transparency, Grafana supports both of these options in its discord notifier and I'd love it if they could be uniform. Being conscious that we're all short on time, I'm happy to address my own comments on top of this PR in case you don't have the time to execute them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One thing about alertmanager-discord is that the username is for some use cases is set to "firing/resolved" because on push notifications, embeds don't show up as easily, so it's easier to work with at a glance

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't really have a strong opinion on this. Would the two of you be fine with taking this into an issue to follow up on and then decide with how to move forward outside this PR?

@metalmatze

Copy link
Copy Markdown
Member Author

LGTM - I think the template can look better (e.g. better formatting when having multiple alerts and adding a link to the silences) but let's see what kind of feedback we get after people start using it.

Overall the messages in Discord could look way better indeed. However, most of the notifications use the same default template for messages. Hence, I opted to use the same one. It's always possible to write custom templates and use them with alertmanager.

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>
@metalmatze

Copy link
Copy Markdown
Member Author

Are we waiting on something? Honestly don't remember.

@simonpasquier simonpasquier 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.

Late to the party but lgtm. I suppose that we can address @gotjosh requests in a later PR?

Even if the current PR is limited, it's a good first step and nothing forbids adding new config options after it merges.

@metalmatze

Copy link
Copy Markdown
Member Author

Does someone want to merge this? I can do that myself, but don't feel like that's a best practice. :)

@simonpasquier

Copy link
Copy Markdown
Member

Hey! I'd like to hear from @gotjosh before merging. But since he's busy these days, I propose to merge it next week in case of no answer from him.

@metalmatze

Copy link
Copy Markdown
Member Author

Given it's been a lot more days, I'll go ahead and merge this. Let me know if there's something we should follow this up with!

@metalmatze metalmatze merged commit 28c3df0 into prometheus:main Oct 25, 2022
@metalmatze metalmatze deleted the discord branch October 25, 2022 16:24
@juliusv

juliusv commented Dec 23, 2022

Copy link
Copy Markdown
Member

@metalmatze Hi, I just noticed that the docs for this are still missing at https://prometheus.io/docs/alerting/latest/configuration/ (source: https://github.com/prometheus/alertmanager/blob/main/docs/configuration.md). Could you add those as well?

@metalmatze

Copy link
Copy Markdown
Member Author

Hey, thanks for the ping. I bookmarked this issue in the hopes to remind myself in my free time to make the contribution.

@juliusv

juliusv commented Jan 4, 2023

Copy link
Copy Markdown
Member

@metalmatze I can take a stab at it today if that's ok with you. If it remains undocumented, it's basically like the feature doesn't exist, so I think it's good to do it now :)

@juliusv

juliusv commented Jan 4, 2023

Copy link
Copy Markdown
Member

PR out at #3201

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.

7 participants