Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
on 05-30-2020 12:15 AM - edited on 10-07-2024 09:28 AM by Ryan.Paredez
Revised May 16, 2022
Many of our customers today want to quickly alert a Slack channel when AppDynamics detects a customer-impacting performance issue with a critical application. If you are one of these joint customers with Slack, we have great news for you: Simple instructions and a template to set up this proactive alerting for your teams.
To create this integration, we’ll use webhooks on both platforms: AppDynamics has an outgoing webhook to send notifications, and Slack has an incoming webhook to receive the notifications from AppDynamics. AppDynamics uses HTTP templates that are backed with a velocity engine so that data can be taken from variables in AppDynamics and sent into Slack. On the Slack side, this integration uses Slack blocks (layout blocks) in the template to format the message sent to Slack.
The template can be modified.
The following steps allow you to set AppDynamics up to send event notifications or alerts to a specific Slack channel. Three main areas need to be configured and set up:
A. Prepare Slack
B. Set up an AppDynamics alert
C. Create an AppDynamics policy to trigger the event or alert
Now that Incoming Webhooks are enabled, the settings page should refresh and some extra options will appear. One of those options will be a button marked Add New Webhook to Workspace, and you should click it.
NOTE | Take note of it for the Request URL step in the Configure AppDynamics Alerting section below, where you will Set the Request URL parameters.
You’re now all set up in Slack. Next, go to AppDynamics to set up the outgoing webhook alert.
NOTE | This template uses the standard Slack “block” technology (as well as the velocity engine in AppDynamics) and can be modified.
Method |
POST |
URL Encoding |
UTF-8 |
MIME Type |
Application/JSON |
|
Payload Encoding |
UTF-8 |
|
(Payload box) |
Download the attached template script and copy and paste it into the “payload 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"
},
]
}
To complete the integration, next, connect this template to an action and application policy.
To complete the integration, tie an application to this template using an action and a policy within AppDynamics.
This completes your creation of the Action for triggering an outbound HTTP request.
Next, create a policy that both triggers the outbound HTTP request action, and binds the action to a particular application.
Now, you have configured a Policy on an application to trigger an action, which then uses the template to send an event or alert (based on the rules you set in the policy) to a particular Slack channel.
Once your application starts generating policy violations, you’ll see them in your AppD-Alerting Slack channel as shown below.
The alert has two buttons. One takes you to the deep link URL in AppDynamics where the alert was generated. You can use the second button to log in and start a WebEx session if needed.
Below is an example of what you could expect to see when you click on the deep link URL.
You can click around here as you would normally do, to see things like the flowmap, calls, errors, and more.
thanks.
Glad you're pleased, @Ahmed.Sorour! Hoping you'll let the Community know how it goes for you!
Claudia Landivar
Community Manager & Editor
Knowledge Base
Great Post!
I have setup the Slack integration with the help of this article.
I am noticing a few things while trying a Test Run:
1. App Server Restart notification is not getting pushed on to slack. Any reasons why?
2. If 2 event types are to be sent simultaneously, i notice only one reaching slack? Is it tool behaviour or am I missing something?
Regards,
Deepika Singh
Hi Deepika,
The first issue I can reproduce, so to fix it please remove 2 lines of code below. Its at the bottom of the template.
#else
"style": "green",
this was an oversight as style=green does not exist in the Slack Block world, so by taking those two line out it will just be the default color.
The second issue I need to understand more, so when you say 2 event types, do you mean from 2 different applications or the same application? Need to understand it more to look into it.
Thanks,
Bill
Minor typographical revision to remove space introduced by platform update.
Claudia Landivar 8/25/23
FYI @Deepika.Singh and @Bill.Harper , I've removed the color code from the article above, so readers will no longer find it:
#else"style": "green",
Thank you both for questions and answers that improve the Community! I'm following the other question with interest.
Claudia Landivar
Community Manager and Editor, Knowledge Base
Hello Expert Team,
I wish to check whether we can get template script or code for creating ServiceNow Incident from APPD.
Thanks
Sharad
We have a ServiceNow Integration. You can read more about it here in our documentation. It's more comprehensive than just opening a ticket in ServiceNow and using the Event Service. Also, we have worked with ServiceNow to build the integration native into their product, so if you look in their store and search for AppDynamics you will find their ServiceGraph connector, which is in Beta. Both of these integrations use an alerting template, but also populate the CMDB with the AppDynamics Application Topology so that when an alert fires, it goes to the Event Service and gets bound to the Application in the CMDB from there it can open a ticket, run an automation script or many other things that a customer might set up. Hope this helps.
Revised 2/6/2023 to fix broken documentation link and minor typos.
Claudia Landivar, Community Manager
This is a really helpful article @Claudia.Landivar and @Bill.Harper - thanks for writing it!
Thanks, @Nina.Wolinsky! It was such a pleasure to work with @Bill.Harper on this.
The known issue, where numbered lists weren't displaying numbers, has been resolved.
Claudia Landivar
Community Manager & Editor
Hi, how to show latestEvent.eventTime in slack with dd/mm/yyyy hh:mm:sssss format?
i tried bu did not work
"type": "mrkdwn",
"text": "*Date:*\n ${latestEvent.eventTime.getYear()}-${latestEvent.eventTime.getMonth()}-${latestEvent.eventTime.getDate()} ${latestEvent.eventTime.getHours()}:${latestEvent.eventTime.getMinutes()}:${latestEvent.eventTime.getSeconds()}"
@cebrail.inanç, while I'm not an expert in this field I did notice this resource and wondered if you had seen it. It is a Class Date Tool on the Apache Velocity site. Might it offer a useful format for your needs?
https://velocity.apache.org/tools/devel/apidocs/org/apache/velocity/tools/generic/DateTool.html
Would you kindly let us know either way? This is bound to come up again for others.
Claudia Landivar
Community Manager & Editor
I tried but the volecity function didn't work.
"type": "mrkdwn",
"text": "latestEvent.eventTime: ${latestEvent.eventTime} \n latestEvent.eventTime.iso: ${latestEvent.eventTime.iso}"
Output: latestEvent.eventTime: Thu Feb 09 02:26:35 TRT 2023
latestEvent.eventTime.iso - ${latestEvent.eventTime.iso}
Getting a HTTP/1.1 400 Bad Request in response status line and response payload as invalid_payload
when doing the test run. No test notification is received on slack either.
Any help would be much appreciated. Thanks.
Hello, @cebrail.inanç and @Nawaz.Mohammed
So far, what I've been able to gather is advice to experiment with the payload, and/or to open a Support ticket. I'll also report back here if I learn anything new or more specific to what you're seeing.
We hope you also share new developments.
Claudia Landivar
Community Manager & Editor
Hello,
Slack notification channels is getting alerts from appd that are new and closed but I feel like the closed one should be able to be configured to actually close the issue in slack. So you only see one thread per issue and you can quickly just see what's open.
Is there anyway we can apply this?
Hello @Muhammad.Chaudhry, what do you mean when you say "close the issue in Slack"?
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form