| 1 | <!--startmeta |
| 2 | custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/health/notifications/discord/README.md" |
| 3 | meta_yaml: "https://github.com/netdata/netdata/edit/master/src/health/notifications/discord/metadata.yaml" |
| 4 | sidebar_label: "Discord" |
| 5 | learn_status: "Published" |
| 6 | learn_rel_path: "Alerts & Notifications/Notifications/Agent Dispatched Notifications" |
| 7 | keywords: ['Discord'] |
| 8 | message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE" |
| 9 | endmeta--> |
| 10 | |
| 11 | # Discord |
| 12 | |
| 13 | |
| 14 | <img src="https://netdata.cloud/img/discord.png" width="150"/> |
| 15 | |
| 16 | |
| 17 | Send notifications to Discord using Netdata's Agent alert notification feature, which supports dozens of endpoints, user roles, and more. |
| 18 | |
| 19 | |
| 20 | <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" /> |
| 21 | |
| 22 | ## Setup |
| 23 | |
| 24 | |
| 25 | ### Prerequisites |
| 26 | |
| 27 | #### |
| 28 | |
| 29 | - The incoming webhook URL as given by Discord. Create a webhook by following the official [Discord documentation](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks). You can use the same on all your Netdata servers (or you can have multiple if you like - your decision). |
| 30 | - One or more Discord channels to post the messages to |
| 31 | - Access to the terminal where Netdata Agent is running |
| 32 | |
| 33 | |
| 34 | |
| 35 | ### Configuration |
| 36 | |
| 37 | #### Options |
| 38 | |
| 39 | The following options can be defined for this notification |
| 40 | |
| 41 | <details open><summary>Config Options</summary> |
| 42 | |
| 43 | |
| 44 | |
| 45 | | Option | Description | Default | Required | |
| 46 | |:-----|:------------|:--------|:---------:| |
| 47 | | SEND_DISCORD | Set `SEND_DISCORD` to YES | YES | yes | |
| 48 | | DISCORD_WEBHOOK_URL | set `DISCORD_WEBHOOK_URL` to your webhook URL. | | yes | |
| 49 | | [DEFAULT_RECIPIENT_DISCORD](#option-default-recipient-discord) | Set `DEFAULT_RECIPIENT_DISCORD` to the channel you want the alert notifications to be sent to. You can define multiple channels like this: `alerts` `systems`. | | yes | |
| 50 | |
| 51 | <a id="option-default-recipient-discord"></a> |
| 52 | ##### DEFAULT_RECIPIENT_DISCORD |
| 53 | |
| 54 | All roles will default to this variable if left unconfigured. |
| 55 | You can then have different channels per role, by editing `DEFAULT_RECIPIENT_DISCORD` with the channel you want, in the following entries at the bottom of the same file: |
| 56 | ```text |
| 57 | role_recipients_discord[sysadmin]="systems" |
| 58 | role_recipients_discord[domainadmin]="domains" |
| 59 | role_recipients_discord[dba]="databases systems" |
| 60 | role_recipients_discord[webmaster]="marketing development" |
| 61 | role_recipients_discord[proxyadmin]="proxy-admin" |
| 62 | role_recipients_discord[sitemgr]="sites" |
| 63 | ``` |
| 64 | |
| 65 | The values you provide should already exist as Discord channels in your server. |
| 66 | |
| 67 | |
| 68 | |
| 69 | </details> |
| 70 | |
| 71 | |
| 72 | |
| 73 | #### via File |
| 74 | |
| 75 | The configuration file name for this integration is `health_alarm_notify.conf`. |
| 76 | |
| 77 | |
| 78 | You can edit the configuration file using the [`edit-config`](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#edit-configuration-files) script from the |
| 79 | Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#locate-your-config-directory). |
| 80 | |
| 81 | ```bash |
| 82 | cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata |
| 83 | sudo ./edit-config health_alarm_notify.conf |
| 84 | ``` |
| 85 | |
| 86 | ##### Examples |
| 87 | |
| 88 | ###### Basic Configuration |
| 89 | |
| 90 | |
| 91 | |
| 92 | ```yaml |
| 93 | #------------------------------------------------------------------------------ |
| 94 | # discord (discordapp.com) global notification options |
| 95 | |
| 96 | SEND_DISCORD="YES" |
| 97 | DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/XXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
| 98 | DEFAULT_RECIPIENT_DISCORD="alerts" |
| 99 | |
| 100 | ``` |
| 101 | |
| 102 | |
| 103 | ## Troubleshooting |
| 104 | |
| 105 | ### Test Notification |
| 106 | |
| 107 | You can run the following command by hand, to test alerts configuration: |
| 108 | |
| 109 | ```bash |
| 110 | # become user netdata |
| 111 | sudo su -s /bin/bash netdata |
| 112 | |
| 113 | # enable debugging info on the console |
| 114 | export NETDATA_ALARM_NOTIFY_DEBUG=1 |
| 115 | |
| 116 | # send test alarms to sysadmin |
| 117 | /usr/libexec/netdata/plugins.d/alarm-notify.sh test |
| 118 | |
| 119 | # send test alarms to any role |
| 120 | /usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE" |
| 121 | ``` |
| 122 | |
| 123 | Note that this will test _all_ alert mechanisms for the selected role. |
| 124 | |
| 125 |