Sending a webhook from Synology DSM to Discord

Given the fact that running a Datadog agent on a Synology Play NAS is not obvious, I wanted to enable Discord webhooks push notifications (as this is where my Datadog alerts are already being sent). This way, I'd get plenty of alerts "for free" without having to configure new Datadog monitors.

While sending webhooks notifications from a Synology NAS to Discord is technically possible, the DSM UI somehow seems to prevent us from doing so, as documented in this forum thread. Somehow, we have to include a hello world message in the notification, as part of the message content, without which, the UI won't allow us to save the webhook configuration.

You can however circumvent the issue by ssh-ing into the NAS and edit the /usr/syno/etc/synowebhook.conf into this:

{
    "Discord": {
        "needssl": false,
        "port": 8090,
        "prefix": "A new system event occurred on your %HOSTNAME%",
        "req_header": "",
        "req_method": "post",
        "req_param": "{\"username\":\"Synology\", \"avatar_url\": \"https://play-lh.googleusercontent.com/HjbYWbXJ-6e6Cia-mBbHDSdontW1yE6MHMaXqlHW80CQegDOEPQ1HGACxvEpnqCUHgo\", \"embeds\": [{\"description\": \"@@TEXT@@\", \"title\": \"@@PREFIX@@\"}]}",
        "sepchar": " ",
        "template": "$webhook_url",
        "type": "custom",
        "url": "$webhook_url"
    }
}

Note: replace $webhook_url by your Discord webhook URL.

When this is done, you should see a Discord webhook in your Webhook Push Services, and you should now be able to send a test message to Discord!

Now, any warning or alert generated from DSM will automatically be sent to Discord as well!

Comments