Discord Notifications

Overview

DISCORD notifications send alert messages, alert detail tables, and charts into Discord channels. This integration is based on the Discord Webhook API.

Security

* Note that attachments (images, files) in Discord messages cannot be securely shared at this time (API v6).
* The attachments, even if sent to a private server, are accessible by any unauthorized user via the URL.

Prerequisites

Install and configure the Web Driver to send chart screenshots directly into Discord.

Create Discord Server

Configure a new Discord server, if necessary.

  • Click on the plus icon in the left panel.

  • Click on Create a Server.

  • Specify Server Name. Click Create.

  • Configure the server for private access.

  • Invite new members to the server, click Done.

Create Channel

  • Click on Create Channel.

  • Specify Channel name, check (enable) Text Channel, click Create Channel.

  • Click Edit channel.

  • Open the Permissions tab and review the settings.

On the Invite tab you can create an invitation link and distribute it to new users.

To join a server, click Create new server, select Join and paste the received invitation link.

Create Webhook in Discord

  • Open the Webhook tab, click Create Webhook, enter a name and select a channel.

    ![](./images/create_webhook.png)
    
  • Copy the Webhook URL for future reference, click Save.

Create Webhook in ATSD

  • Open the Alerts > Outgoing Webhooks page.

  • Click on an existing DISCORD template, or click Create and select the DISCORD type.

  • Specify the unique Name of the notification.

  • Copy the Webhook URL from the Discord client into the Webhook URL field in the configuration form.

  • The Webhook ID and Webhook Token are filled automatically when you finish editing the Webhook URL field.

  • Select Test Portal to test the screenshot.

  • Click Test.

  • If test is passed, set the status Enabled and click Save.

Proxy Settings

If the Discord API server is not directly accessible from the ATSD server, open the Network Settings and specify proxy parameters.

NGINX API Gateway Path for Discord:

  location /api/webhooks {
      proxy_pass https://discordapp.com/api/webhooks;
  }

Webhook Parameters

Parameter Description
Webhook URL Webhook URL generated on the Webhook tab in channel settings. The url is cleared when configuration is saved.
Webhook ID The ID of the webhook. Automatically resolved from Webhook URL.
Webhook Token The secure token of the webhook. Automatically resolved from Webhook URL.
Bot Username Overwrite your bot user name.
Content Message text to be sent. Leave the field blank to make the field editable in the rule editor.

Testing

Create/import rule

  • Create a new rule or import an existing rule for a built-in metric as described below.
  • Download the file rules.xml.
  • Open the Alerts > Rules > Import page.
  • Check (enable) Auto-enable New Rules, attach the rules.xml file, click Import.

Configure notification

  • Open Alerts > Rules page and select a rule.
  • Open the Webhooks tab.
  • Select Discord from the Endpoint drop-down.
  • Enable the OPEN, REPEAT, and CANCEL triggers.
  • Customize the alert message using placeholders as necessary, for example:
      OPEN = [${status}] ${rule} for ${entity} ${tags}. ${ruleLink}
    REPEAT = [${status}] ${rule} for ${entity} ${tags}. Duration: ${alert_duration_interval}. ${ruleLink}
    CANCEL = [${status}] ${rule} for ${entity} ${tags}. Duration: ${alert_duration_interval}. ${ruleLink}
  • Click Save to save the rule.

  • The rule creates new windows when new commands are received by the database.

It may take a few seconds for the first commands to arrive and to trigger the notifications. You can open and refresh the Alerts > Open Alerts page to verify that an alert is open for your rule.

Examples

Content of atsd.jvm.low_memory_atsd_open_20171127_1408043.txt: