cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Bill.Harper
AppDynamics Team

What is the procedure for connecting an AppDynamics HTTP template to a dedicated Slack channel?

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.

In this article...


 

What are the steps to integrating with Slack?

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 

Back to Top

 

A. Prepare Slack to receive AppDynamics alerts

  1. Create a Slack App using this link. Pick a name, choose a workspace to associate your app with, and then click Create App. This app will help you post messages in Slack. You can also use any existing Slack App you have.
    ClaudiaLandivar_0-1652733856148.png
    ClaudiaLandivar_1-1652733910338.png

  2. After creating the app, you will be redirected to the settings page for your new app (if you are using an existing app, just load its settings via your app's management dashboard).

  3. From here select the Incoming Webhooks feature, and click the Activate Incoming Webhooks toggle to switch it on.
    ClaudiaLandivar_2-1652734007346.png
    ClaudiaLandivar_3-1652734042250.png
  4. 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.

    ClaudiaLandivar_4-1652734101364.png

     

  5. Go ahead and pick a channel that the app will post to, and then click to Authorize your app. You'll be sent back to your app settings, and you should now see a new entry under the Webhook URLs for Your Workspace section, with a Webhook URL that'll look something like this:
    https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
    ClaudiaLandivar_5-1652734178090.png

     

    ClaudiaLandivar_6-1652734186436.png

  6. This webhook URL generated by Slack will be used in AppDynamics as the target for the event notifications or alerting.

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.

Back to Top


 

B. Prepare AppDynamics to Send Alerts to Slack

NOTE | This template uses the standard Slack “block” technology (as well as the velocity engine in AppDynamics) and can be modified.

  1. In AppDynamics, create a new HTTP template (Alert & Respond > HTTP Request Templates > New) by first navigating to the option on the top tab, then clicking on HTTP Request Templates on the sidebar menu. 
    In AppDynamics, create a new HTTP template on the Alert & Respond pageIn AppDynamics, create a new HTTP template on the Alert & Respond page

     

  2. Configure the outbound webhook for event notifications and give it a name. Typically it’s best to name it after the application that will use it. 

  3. Set the Request URL parameters as: 

    Method

    POST

    Raw URL

    The URL from Slack in Section 1 - Prepare Slack, step 6 

    URL Encoding

    UTF-8


    image1.png



  4. Scroll down the Create HTTP Template dialog to Payload and choose the following:

    MIME Type 

    Application/JSON

    Payload Encoding

    UTF-8

    (Payload box)

    Download the attached template script and copy and paste it into the “payload box”


    Use this template script for 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"
    		},
    	]
    }​


    Here's an example of what adding the script template to the Create HTTP Template, Payload section in AppDynamics looks like
    Example of adding the script template to the Create HTTP Template, Payload section in AppDynamicsExample of adding the script template to the Create HTTP Template, Payload section in AppDynamics
  5. Finally, click the Save button. Now the template is configured.

  6. Test the template configuration. Click the Run Test button on the bottom of the page and choose some events to send over. 

    The HTTP Action Template TestThe HTTP Action Template Test

     

  7. Navigate to the Slack channel you set up. You should see a sample alert, like the “New Warning Health Rule Violation” shown below.

Test Health Rule violation warningngTest Health Rule violation warningng

 

To complete the integration, next, connect this template to an action and application policy

Back to Top


 

C. Set Up an Action and Policy in AppDynamics to Trigger the Event or Alert

To complete the integration, tie an application to this template using an action and a policy within AppDynamics. 

 

Set up an Action

  1. First, choose an application from the pulldown menu. Then, go to the Alert & Respond tab, and choose Actions on the sidebar menu.

    After choosing an application, go to Alert & Respond > ActionsAfter choosing an application, go to Alert & Respond > Actions

     

  2. Next, create a new action. You’ll point this action at the template you created above.

    Go to the last section, choose the application, and click Create Action. In the Create Action dialog box, define the type of action to create by choosing HTTP Request. Click OK.

    Create Action dialogCreate Action dialog

     

  3. Once you click OK, the Create HTTP Action dialog box will open. At the HTTP Request Template, enter the name of the HTTP action.

    Then, from the drop-down, choose which template this action will use (In this example, the HTTP template was called “Slack-Alert”). Click OK. 

    Choose the HTTP Request Template for this ActionChoose the HTTP Request Template for this Action

     



  4. At the Create HTTP Action screen, click Save to confirm. 
    Completed Create HTTP Action dialogCompleted Create HTTP Action dialog

This completes your creation of the Action for triggering an outbound HTTP request

 

Create a policy

Next, create a policy that both triggers the outbound HTTP request action, and binds the action to a particular application. 

  1. From the Actions and Alerts option, select Policy, then click Create a New Policy. Select the desired application.

    Create the new policy screenCreate the new policy screen

     

     

  2. Click the Create button. Name the policy, then configure which events will trigger this alert.

    See the example of how one might configure the policySee the example of how one might configure the policy

     

  3. Next, go to the Actions tab on the top menu and select the “+”. From the list, choose an action to tie to this Policy, then click Save.

    Under Actions, choose an action to tie to the policyUnder Actions, choose an action to tie to the policy

     

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. 

Back to Top


 

How do I use my AppDynamics integration within Slack?

Once your application starts generating policy violations, you’ll see them in your AppD-Alerting Slack channel as shown below. 

Example of the policy violation notice in SlackExample of the policy violation notice in Slack

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. 

Example of the deep link URL destinationExample of the deep link URL destination

 


You can click around here as you would normally do, to see things like the flowmap, calls, errors, and more.

18 image5.png

Back to Top

 

Resources

Comments
Ahmed.Sorour
Producer

thanks.

Claudia.Landivar
AppDynamics Team (Retired)

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

Deepika.Singh
Builder

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

 

Bill.Harper
AppDynamics Team

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

Claudia.Landivar
AppDynamics Team (Retired)

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

Sharad.Srivastava
New Poster

Hello Expert Team,

 

I wish to check whether we can get template script or code for creating ServiceNow Incident from APPD.

 

Thanks

Sharad

Bill.Harper
AppDynamics Team

Hi @Sharad.Srivastava 

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

Nina.Wolinsky
Community Manager

This is a really helpful article @Claudia.Landivar and @Bill.Harper - thanks for writing it!

Claudia.Landivar
AppDynamics Team (Retired)

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

 

 

cebrail.inanç
Explorer

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()}"

 

 

 

Claudia.Landivar
AppDynamics Team (Retired)

@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

cebrail.inanç
Explorer

@Claudia.Landivar ,

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}

Nawaz.Mohammed
New Member

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.

Claudia.Landivar
AppDynamics Team (Retired)

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? 

Shubhankar.Yash
AppDynamics Team (Retired)

Hello @Muhammad.Chaudhry,  what do you mean when you say "close the issue in Slack"?

Hello Community.

We have integrated slack with AppDynamics and also in the slack channel we can see that it is showing that new integration has been successful but still we are not getting any alerts after any HR is violated.

 

 

Bill.Harper
AppDynamics Team

Hi Jeevanjyoti,

Can you run the test from the template and does that work and show up in slack? The test button is in the lower right hand corner of the Alerting Template next to save.  First make sure you can get this test mode to work.

BillHarper_0-1729269755027.png

It should produce this in slack

BillHarper_3-1729273451393.png

 

To Trigger an alert from an application you need to have a Policy set against a health rule that will trigger the action that consumes the webhook template that points to the Slack Webhook URL. 

BillHarper_1-1729273053960.png

BillHarper_4-1729273789179.png

 

I know this works, I recently set it up again and it works just fine. 

Health Rule Violation -> Policy -> Action -> Webhook payload sent to Slack Webhook URL. 

The Policy connects the HR violation to the Action you want to take, webhook, email ... and more. 

 

 

Version history
Last update:
‎10-07-2024 09:28 AM
Updated by:
Join Us On December 10
Learn how Splunk and AppDynamics are redefining observability


Register Now!

Observe and Explore
Dive into our Community Blog for the Latest Insights and Updates!


Read the blog here