Download PDF
Download page Predefined Templating Variables.
Predefined Templating Variables
This page describes the predefined variables that can be used in an HTTP request template or in an email template. The policy engine substitutes the value of the variable in the context of the triggering event(s) when it sends the actual request or email.
Form Variable Names
To form a predefined variable name, combine the base name of the variable with a field of its corresponding info class. You can use the base name with the corresponding info class only for example, you can use the base name action with info class ActionInfo only
.
If an info class has no fields associated, use the base name as the variable. For example, to use the controller URL as a variable in a template, use ${controllerUrl}
.
If an info class comprises multiple fields, select a single field and associate it with the base name. For a list of fields associated with an info class, see Info Class Fields.
For example:
- To use the account name as a variable in a template, combine the base name
account
with thename
field of theEntityInfo
class to form the variable${account.name}
. - To use the trigger time of an action as a variable, combine the base name
action
with thetriggerTime
field of theActionInfo
class to form the variable${action.triggerTime}
.
You can chain the segments of a variable name where the info class field type is yet another info class.
For example, to use the name of an application in which the latest triggering event occurred:
- Combine the latestEvent
application
field of theEventInfo
class. - The field type of the
application
field isEntityInfo
which is yet another info class, hence select the name field of theEntityInfo
class. Form the variable name by appending the segments:
{ <base name>.<field name of info class1>.<field name of info class2>}
${latestEvent.application.name}.
Base Names
This tables describes the base names for the predefined variables with their corresponding info classes.
Base Name | Description | Info Class |
---|---|---|
account | Account in which the action was triggered. | EntityInfo |
policy | Policy that triggered the action. | PolicyInfo |
action | Triggered action. | ActionInfo |
topSeverity | INFO , WARN or ERROR. | NotificationSeverity |
topSeverityImage | Severity image or icon. | ImageInfo |
notificationConfigText | Email actions only. | String |
controllerUrl | URL of the controller. | String |
appDynamicsIcon | - | ImageInfo |
appDynamicsLogo | - | ImageInfo |
latestEvent | Most recent triggering event. | EventInfo |
fullEventList | List of events that triggered the action. | List<EventInfo> |
fullEventsByTypeMap | List of events that triggered the action, grouped by type. | Map<String, List<EventInfo>> |
clampLimit | Optional setting, limit on how many triggering events to display. | int |
clamped | True if clamp limit is set. | boolean |
clampedEventList | n most recent triggering events if clamped. | List<EventInfo> |
clampedEventsByTypeMap | n most recent triggering events if clamped, grouped by type. | Map<String, List<EventInfo>> |
| Node level variables to be used in email and HTTP templates. | Map<EventInfo, NodeTemplateVariables> |
Info Class Fields
From the previous Base Names table, use the fields in the appropriate class to form the variable to use in a template.
class EventInfo {
EventType eventType
long id
String guid
String eventTypeKey
Date eventTime
String displayName
String summaryMessage
String eventMessage
EntityInfo application
EntityInfo tier
EntityInfo node
EntityInfo db
List<EntityInfo> affectedEntities
boolean healthRuleEvent
EntityInfo anomaly // * Only defined in case of anomaly event
EntityInfo healthRule // * Only defined when healthRuleEvent == true
EntityInfo incident // * Only defined when healthRuleEvent == true
boolean healthRuleViolationEvent
NotificationSeverity severity
ImageInfo severityImage
boolean btPerformanceEvent // * true when eventType matches one of the BT performance event types
String deepLink
}
class ImageInfo {
String name
String fileName
String mimeContentRef
String deepLink
}
class EntityInfo {
EntityType entityType
String entityTypeDisplayName
long id
String name
}
class ActionInfo extends EntityInfo {
Date triggerTime
}
class PolicyInfo extends EntityInfo {
boolean digest
digestDurationInMins
}
class PolicyInfo {
EntityType entityType
String entityTypeDisplayName
long id
String name
boolean digest
int digestDurationInMins
}
class ActionInfo {
EntityType entityType
String entityTypeDisplayName
long id
String name
Date triggerTime
}
enum NotificationSeverity { INFO, WARN, ERROR }
class NodeTemplateVariables {
private long id;
private String name;
private long tierId;
private String tierName;
private long machineId;
private String machineName;
private boolean machineAgentPresent;
private String machineAgentVersion;
private boolean appAgentPresent;
private String appAgentVersion;
private String ipAddresses;
private AgentType agentType;
}
The private String ipAddresses
field contains hostnames instead of IP addresses.
Examples
HTTP request example for most recent triggering event:
http://myController:8080/controller/rest/applications/${latestEvent.application.name}/nodes/${latestEvent.node.name}
HTTP request example iterating through a list of triggering events:
#foreach(${event} in ${fullEventList})
http://myController:8080/controller/rest/applications/${event.application.name}/nodes/${event.node.name}
#end
Email with dynamically varying subject example:
If you have several health rules to monitor your application and one policy to send email notification for all the health rules, you might find it difficult to search for the correct information in the notification. You can define a variable to dynamically update the email subject based on the event that triggered the notification.
Ensure that you define the subject variable in the email body and include it in the subject field.
Subject: $subject
Body:
...
<!-- Subject changes dynamically based on the triggering event -->
#set($subject = #foreach(${events} in ${fullEventList}) ${events.eventType} #end )}
...
Email HTML body example:
AppDynamics uses this email template to notify the details of the events occurring on an application. You can customize the required event details you want notified by enabling the event types.
<!-- Default AppDynamics email template -->
#if( $!{notificationConfigText} != '' )
$!{notificationConfigText}
#else
AppDynamics
#end
Event Notification for the "${latestEvent.application.name}" Application
Event Notification Name: ${policy.name}
Event Notification Severity: ${topSeverity}
Summary of events occurring during the ${policy.digestDurationInMins}+ minute(s) prior to ${action.triggerTime}:
## Summary table
|| Event Type | Count ||
## Copy this row for each event type and count
#foreach($eventTypeEntry in $fullEventsByTypeMap.entrySet())
|| ${eventTypeEntry.getKey()} | ${eventTypeEntry.getValue().size()} ||
#end
## Full List of Events
The following events occurred during the time frame:
#if ($clamped)
Warning: The event list has been clamped at ${clampLimit} results! Please see the event and/or request snapshot viewers for the full list of events.
#end
|| Event Time | Event Type | Severity | Tier | Node | Summary ||
#foreach($eventList in $clampedEventsByTypeMap.values())
#foreach($event in $eventList)
|| ${event.eventTime} | ${event.displayName} | ${event.severity} | $!{event.db.name} | $!{event.tier.name} | $!{event.node.name} | ${event.summaryMessage} ||
#end
#end
Event Notification from AppDynamics.
This is an auto-generated email summarizing events on the "${latestEvent.application.name}" application. You are receiving this because you are configured as a recipient on the "${policy.name}" event notification. This is not necessarily an exhaustive list of all events during this time frame. Only those event types enabled in the notification will appear in this message.
Example to extract event details using iteration:
These examples iterate through the eventList
to extract the details of each event occurring during the specified time.
<h1>Summary of events occurring during the ${policy.digestDurationInMins}+ minute(s) prior to ${action.triggerTime}:</h1>
<table>
#foreach(${eventList} in ${fullEventsByTypeMap.values()})
#foreach(${event} in ${eventList})
<tr>
<td>
<!-- Event icon -->
<img src="${event.severityImage.mimeContentRef}" alt="${event.severity}" />
</td>
<td>
<!-- Event name with event link -->
<a href="${event.deepLink}">${event.displayName}</a>
</td>
<td>
<!-- Event message -->
${event.eventMessage}
</td>
</tr>
#end
#end
</table>
Example code to list all variables:
<h1>variables below </h1>
${fullEventsNodeMap}
<h2>map elements below</h2>
#foreach(${value} in ${fullEventsNodeMap.values()})
${value}
${value.name}
#end
If these predefined variables do not meet your needs, you can define your own custom variables for use in these templates in the Create Template pane.