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

Table of Contents

Background

Velocity Variables

Sample Payloads for HTTP Request Templates

Additional Resources

 

Background

If you create health rule policies that trigger HTTP request actions or email notifications, you can use templates to customize the HTTP request or email message and render specific values when the action is triggered. These templates have a set of predefined variables that are processed using Apache Velocity Engine v1.7.

 

  • For HTTP request actions, templates describe the HTTP request. You can use variables that replace values in the URL path and payload when the HTTP request is sent.
  • For emails, you can use a template with variables to replace values in the body of the message.

 

You can configure custom variables if you need something beyond the predefined ones. This article provides examples of how you can use different Apache Velocity Template variables in HTTP request action and email templates.

 

Velocity Variables

The table below describes widely used Velocity variables to help you become more familiar with Velocity when you are customizing templates. A variable consists of a leading “$” followed by an identifier. It should look like this: $foo

 

Description Variable
A custom variable Usage: $foo
Set a variable #set ($message = "Hello")
If statement

#if ($message == "Hello")

 Message received and is "Hello"

#end

Replace HTML tags #set( $sm = $sm.replace("<b>", "[") )
Escape characters $esc.java(${latestEvent.summaryMessage})
Get the first element from an Array/List

${latestEvent.affectedEntities[0].name}

${latestEvent.affectedEntities[0].entityTypeDisplayName}

Loop through an Array/List #foreach( ${entity} in ${latestEvent.affectedEntities} )${entity.name}#if( $foreach.hasNext ),#end#end
Split #set ($summary = ${latestEvent.summaryMessage})
#set ($job = $summary.split(" "))
summary: $summary
Job: $job[2]
Job2: $job.get(2)
Replace #set( $sm = $!{latestEvent.summaryMessage.replace('"',"*")} )
#set( $sm = $sm.replace("<b>", "[") )
#set( $sm = $sm.replace("</b>", "]") )
#set( $sm = $sm.replace("<br>", " ") )

 

Sample Payloads for HTTP Request Templates 

This article includes a sample HTTP request template payload for Hipchat. To learn about converting event time formats, or creating SMS or Slack alerts, see the resources below.

 

Additional Resources

Comments
null.null
Creator

Is there a template that can be used for splunk?

Rugved.Sarode
AppDynamics Team

Hello,
As a prerequisite, please make sure your POST api successfully works
outside AppDynamics UI, using curl / Postman Client / Google Rest client.

The same POST api can be translated within AppDynamics UI- Alert and
Respond -> HTTP Request Template. The variables (link below) will then act
as a placeholder.

You may use any splunk payload used for a POST api, within the "Body"
section of HTTP Request Template, and replace "values" with variables
(below link) for runtime values.

https://docs.appdynamics.com/display/PRO45/Predefined+Templating+Variables

If you need additional information, please create a ticket within the Support Portal. Please note that only Company Admins can open Support tickets.

Version history
Last update:
‎06-02-2020 03:22 PM
Updated by: