Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notify/discord: Create Discord integration #2948

Merged
merged 1 commit into from Oct 25, 2022

Conversation

metalmatze
Copy link
Member

@metalmatze metalmatze commented Jun 17, 2022

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

benjojo commented Jun 17, 2022

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

@metalmatze
Copy link
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. ☺️

notify/discord/discord.go Outdated Show resolved Hide resolved
Copy link
Member

@gotjosh gotjosh left a comment

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.

config/config.go Outdated Show resolved Hide resolved
config/notifiers.go Outdated Show resolved Hide resolved
APIURL *SecretURL `yaml:"api_url,omitempty" json:"api_url,omitempty"`

Title string `yaml:"title,omitempty" json:"title,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Copy link
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

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
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
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
Member Author

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

Copy link
Member

@simonpasquier simonpasquier left a comment

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

juliusv commented Dec 23, 2022

@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
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
Copy link
Member

juliusv commented Jan 4, 2023

@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
Copy link
Member

juliusv commented Jan 4, 2023

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.

None yet

7 participants