How to setup Discord notifications for Netdata alarms?

Environment

Netdata Agent/Cloud and DiscordApp

Problem/Question

Despite reading the documentation here, I am still very confused on how to send Netdata notifications to Discord.

role_recipients_discord[sysadmin]="systems"
role_recipients_discord[dba]="databases systems"
role_recipients_discord[webmaster]="marketing development"

What I expected to happen

I want to know what I need to place in the square brackets and quotes.

The keywords systems , databases , marketing , development are discordapp.com channels (they should already exist within your discord server).

implies to me that the text in the quotes are channel names, which doesn’t make sense because Discord doesn’t permit spaces in channel names.

Why is the role necessary if the purpose is simply sending notifications to channel?

And how can I input channel ID instead of channel name? In Discord it’s possible to have unlimited duplicated channel names as long as they are in separate categories.

Hello @XP_Mai,

Let me try to clarify our documentation, I did not work with Discord, but I have worked with other Notification methods used with Netdata. Firstly it is necessary to edit the main variables for discord:

1 - Please, go to /etc/netdata and run

$ sudo ./edit-config health_alarm_notify.conf

when your favorite editor opens, set the next variables:

# enable/disable sending discord notifications
SEND_DISCORD="YES"

# Create a webhook by following the official documentation -
# https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks
DISCORD_WEBHOOK_URL="https://discordapp.com/api/webhooks/XXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

# if a role's recipients are not configured, a notification will be send to
# this discord channel (empty = do not send a notification for unconfigured
# roles):
DEFAULT_RECIPIENT_DISCORD="alarms"

According our documentation and some examples we have inside health_alarm_notify the default values for the vector are:

role_recipients_discord[sysadmin]="${DEFAULT_RECIPIENT_DISCORD}"
role_recipients_discord[domainadmin]="${DEFAULT_RECIPIENT_DISCORD}"
role_recipients_discord[dba]="${DEFAULT_RECIPIENT_DISCORD}"
role_recipients_discord[webmaster]="${DEFAULT_RECIPIENT_DISCORD}"
role_recipients_discord[proxyadmin]="${DEFAULT_RECIPIENT_DISCORD}"
role_recipients_discord[sitemgr]="${DEFAULT_RECIPIENT_DISCORD}"

You add and change them according your necessity.

I took a look in the main script used to send data, and I observed that the spaces are used to separate the channels, so if you have spaces, the words will be considered different channels.

The variable declaration role_recipients_discord[sysadmin] means that you have a role named sysadmin that sends data to channel systems.. I think our documentation needs an update here.

Finally you can also test if your configuration is delivering correctly the alarms running the following commands:

$ cd /usr/libexec/netdata/plugins.d/
$ ./alarm-notify test

Best regards!

Thanks @Thiago_Marques_0 for jumping in.

@joel perhaps some great feedback for improvement on the docs? What do you think?

1 Like

The notification docs admittedly haven’t gotten as much love as a lot of other areas.

I’ll work with @Thiago_Marques_0 to come up with a new template/paradigm for organizing all of these individual notifications docs (hopefully with more immediate value), and then over time we’ll bring the same format to every notification doc.

Each of these docs should also probably link to both the enable notifications doc and the reference for full context.

1 Like