cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HTTP Request Template predefined variables not filled

Doug.Odegaard
Builder

I have an HTTP template that does not have some of the predefined variable completed when posts happen.  Here is an example.  Many of them work fine but others do not.  Any advice or guides on how to do this?  I have exhausted the documentation on this. One of them is {latestEvent.deepLink} which comes back as null all the time. In addition {latestEvent.node.name} seems to never be completed either.  Thanks.

 

Template (actual obfuscated data below it as integrated)

{
"incident_key": "${latestEvent.node.name} - ${latestEvent.application.name}",
"description": "${latestEvent.displayName} on ${latestEvent.application.name}",
"client": "AppDynamics",
"client_url": "${controllerUrl}",
"details": {
"Event Name": "${latestEvent.displayName}",
"Summary": "${latestEvent.summaryMessage}",
"Event ID": ${latestEvent.id},
"GUID": "${latestEvent.guid}",
"Event Time": "${latestEvent.eventTime}",
"Event Type": "${latestEvent.eventType}",
"Event Type Key": "${latestEvent.eventTypeKey}",
"Application Name": "${latestEvent.application.name}",
"Node Name": "${latestEvent.node.name}",
"Message": "${latestEvent.eventMessage}",
"Severity": "${latestEvent.severity}"
},
"contexts":[
{
"type": "image",
"src": "${latestEvent.severityImage.deepLink}",
"alt": "${latestEvent.severity}"
},
{
"type": "link",
"href": "${latestEvent.deepLink}",
"text": "View this transaction in AppDynamics"
}
]
}

 

Here is an actual integrated sample of an actual POST

{
"incident_key": "${latestEvent.node.name} - xxx Company",
"description": "Health Rule State changed from Critical to Warning on xxx Company",
"client": "AppDynamics",
"client_url": "https://abcd.saas.appdynamics.com",
"details": {
"Event Name": "Health Rule State changed from Critical to Warning",
"Summary": "AppDynamics has detected a problem with Business Transaction abc downgraded in severity and is now <b>warning</b>.",
"Event ID": "3399999093",
"GUID": "4c2cb73f-1791-461d-9848-x78fa10d17a7",
"Event Time": "Fri Sep 06 15:33:55 PDT 2019",
"Event Type": "POLICY_DOWNGRADED",
"Event Type Key": "Health Rule",
"Application Name": "xxx Company",
"Node Name": "${latestEvent.node.name}",
"Message": "AppDynamics has detected a problem with Business Transaction abc downgraded in severity and is now <b>warning</b>.<br>All of the following conditions were found to be violating<br>For Application <b>xxx Company</b>:<br>1) Errors<br><b>Errors per Minute's</b> value <b>21.00</b> was <b>greater than</b> baseline-based calculated value <b>8.00</b> by <b>2.00</b> standard deviation(s) <b>4.94</b>. Baseline used here is '<b>Weekly Trend - Last 3 months</b>' for the last <b>9</b> minutes<br>2) Calls<br><b>Errors per Minute's</b> value <b>21.00</b> was <b>greater than</b> the threshold <b>1.00</b> for the last <b>9</b> minutes<br>3) Error Percentage<br><b>Error Percentage's</b> value <b>23.00</b> was <b>greater than</b> the threshold <b>10.00</b> for the last <b>9</b> minutes<br>",
"Severity": "WARN"
},
"contexts": [
{
"type": "image",
"src": "https://abcd.saas.appdynamics.com/images/PI_WARNING_small.png",
"alt": "WARN"
},
{
"type": "link",
"src": null,
"alt": null
}
]
}

 

7 REPLIES 7

Eric.Miller
Architect

I'm no expert, but I've fiddled around with some e-mail templates using the predifined variables, the language they're using is called "Apache Velocity" so you can google that and find out more about how the syntax should work. You need to "set" the variables first and then call them later. We have an email template in place which uses something like the code shown below. (so maybe you can extrapolate from there? Code may be a bit off because the message boards strip html) You also need to ensure your deeplinks are set correctly in your domain.xml file on your controller (see here: https://community.appdynamics.com/t5/Knowledge-Base/How-do-I-modify-the-deep-link-URL-in-alert-email...). Also be sure to use the "test" feature to make sure you got it right :

 

Subject: $subject

 

<!-- BEGIN -->
<!-- Grab & Clean Up Event Message to remove the html <b> and slashes clutter -->
#set( $em = $!{latestEvent.eventMessage.replace('"',"*")} )
#set( $em = $em.replace("<b>", "*") )
#set( $em = $em.replace("</b>", "*") )
#set( $em = $em.replace("<br>", " ") )
 
<!-- Gather Interesting Data From Event -->
#set($appName     = "${latestEvent.application.name}")
#set($severity    = "${latestEvent.severity}")
#set($nodeName    = "${latestEvent.node.name}")
#set($tierName    = "${latestEvent.tier.name}")
#set($serverName  = $em.replaceAll('[\s\S]+(?:\s+)(.*)\s+started.*','$1')
#set($machineName = "${fullEventsNodeMap.machineName}")
#set($freeSpace   = $em.replaceAll('[\s\S]+(?:value\s+)(.*)\s+was.*','$1')
#set($cpuUsed = $em.replaceAll('[\s\S]+(?:value\s+)(.*)\s+was.*','$1') )
 
<!-- Set Message Subject -->
#set($subject   = "$severity - YOUR MESSAGE: node:$nodeName, tier:$tierName , server:$serverName,  free:$freeSpace")
 
<!-- Set Message Body  -->
Application : $nodeName
Node        : $nodeName
Tier        : $tierName
Server      : $serverName
Machine     : $machineName
Free Space  : $freeSpace
Message     : $em
 
<!-- Test  -->
eventTime      = ${latestEvent.eventTime}
displayName    = ${latestEvent.displayName}
severity       = ${latestEvent.severity}
database       = $!{latestEvent.db.name}
tier           = $!{latestEvent.tier.name}
node           = $!{latestEvent.node.name}
summaryMessage = ${latestEvent.summaryMessage}
<!-- END -->




Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.

Doug.Odegaard
Builder

We are on the SaaS offering and I am looking only at the built in variables for the HTTP template. Thanks for the note on Apache Velocity. If you can help me troubleshoot the controller-based deepLink to the latestEvent object that would be great.

Because of the code, my posts keep getting marked as SPAM and automatically deleted. So I'll be brief:

 

My advice is to practice with an "email template" first. It has a really good "Test" function which allows you to play around with the code, trigger a condition, and then get an email on it showing you what it'll look like, while also checking for syntax errors. Then I'd move it into the HTTP Requests from there. Your go to document for which variables you can call is this: https://docs.appdynamics.com/display/PRO45/Predefined+Templating+Variables

It's a small list of variables, I know, so you have to get really creative, such as trying to strip the variables out of the deeplink or out of the message summary if possible. For syntax help, you can go to the Apache velocity site for help: http://velocity.apache.org/

I would start small with just displaying something like the summary message and deeplink, and then add on one at a time from there. deeplink should just be ${latestEvent.deepLink} and summary should be ${latestEvent.summaryMessage} (they're case sensetive)

It's a very limited language, so it may be that you are unable to pull the exact variable you want. Remember to use the #set function to build out your strings if possible. I wish you way more than luck!





Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.

Thank you so much for the reply!  I will check out the velocity site and will get with AppD support on our controller support.  Cheers!  Doug

@Doug.Odegaard @Eric.Miller,

 

I checked our spam filter and have since removed @Eric.Miller's post from spam so you can see his original post up in the conversation list. That may provide some more insight. 

 

Best,

 


Thanks,

Ryan, Cisco AppDynamics Community Manager




Found something helpful? Click the Accept as Solution button to help others find answers faster.

Liked something? Click the Thumbs Up button.



Check out Observabiity in Action

new deep dive videos weekly in the Knowledge Base.

Hi @Eric.Miller,

 

Can you share the template you prepared last?

Hey Eric,

 

Thanks you for sharing details. I'm facing a similar issue where my description is coming in HTML and need to format it in plain text. We have a SaaS Controller and I'm unsure where I can use this below script to replace HTML tags.

 

#set( $em = $!{latestEvent.eventMessage.replace('"',"*")} )
#set( $em = $em.replace("<b>", "*") )
#set( $em = $em.replace("</b>", "*") )
#set( $em = $em.replace("<br>", " ") )
 
Regards,
Aniruddha Salve