PDF
Download PDF
Download page Create a Template for Slack.
Create a Template for Slack
To send an HTTP request action to Slack from AppDynamics, you must create a template in AppDynamics. When AppDynamics triggers an action in response to an event, you can view the details of the action in your Slack channel.
This document contains references to the Slack documentation. AppDynamics does not own any rights and assumes no responsibility for the accuracy or completeness of such third-party documentation.
Before you Begin
- Create an app in Slack by using the Slack API wizard. This app accepts the HTTP requests sent to Slack.
Copy the webhook URL generated by the Slack app and keep it securely for later use. AppDynamics uses this URL as a target to send alerts to Slack.
Create a Template in AppDynamics
- In the menu bar, click Alert & Respond.
- Click HTTP Request Templates.
- Enter a name for the template. For example,
Send alerts to Slack
. - In the Request URL section:
- Select POST as Method.
- Enter the webhook URL of the Slack app in the Raw URL field.
- Select UTF-8 as URL Encoding.
- In the Authentication section, select NONE as Type. If you want to enable mutual TLS authentication, select Also Turn on Mutual TLS. For more information about mutual TLS, see Configure and Enable Mutual TLS Authentication.
- In the Payload section:
- Select application/json as MIME Type.
- Select UTF-8 as Payload Encoding.
Enter the following payload in the text box:
#set( $sm = $!{latestEvent.summaryMessage.replace('"',"*")} ) #set( $sm = $sm.replace("<b>", "*") ) #set( $sm = $sm.replace("</b>", "*") ) #set( $sm = $sm.replace("<br>", " ") ) #set( $sm = $sm.replace("null"," ") ) { "blocks": [ { "type": "section", "text": { #if( ${latestEvent.severity} == "ERROR" ) "type": "mrkdwn", "text": ":red_circle: *New Alert from AppDynamics:* ${latestEvent.displayName}\n\n*Summary:*\n$sm" #elseif( ${latestEvent.severity} == "WARN" ) "type": "mrkdwn", "text": ":warning: *New Alert from AppDynamics:* ${latestEvent.displayName}\n\n*Summary:*\n$sm" #else "type": "mrkdwn", "text": ":information_source: *New Alert from AppDynamics:* ${latestEvent.displayName}\n\n*Summary:*\n$sm" #end }, "accessory": { "type": "image", "image_url": "https://share-logos.s3-us-west-1.amazonaws.com/appd-s-logo.png", "alt_text": "logo" }, }, { "type": "section", "fields": [ { "type": "mrkdwn", "text": "*Application:*\n${latestEvent.application.name}" }, { "type": "mrkdwn", "text": "*When:*\n${latestEvent.eventTime}" }, { "type": "mrkdwn", "text": "*Tier:*\n${latestEvent.tier.name}" }, { "type": "mrkdwn", "text": "*Severity:*\n${latestEvent.severity}" }, { "type": "mrkdwn", "text": "*Node:*\n${latestEvent.node.name}" }, { "type": "mrkdwn", "text": "*Triggered by:*\n${policy.name}" }, ] }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "emoji": true, "text": "Go to Alert in AppDynamics" }, #if( ${latestEvent.severity} == "ERROR" ) "style": "danger", #elseif( ${latestEvent.severity} == "WARN" ) "style": "primary", #end "value": "click_me_123", "url": "${latestEvent.deepLink}" }, { "type": "button", "text": { "type": "plain_text", "emoji": true, "text": "Start Webex Session" }, "style": "primary", "value": "click_me_123", "url": "https://cisco.webex.com" } ] }, { "type": "divider" }, ] }
JSON
- In the Settings section, select the One Request Per Event option.
- Click Save.