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 the name field of the EntityInfo class to form the variable ${account.name}.
  • To use the trigger time of an action as a variable, combine the base name action with the triggerTime field of the ActionInfo 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:

  1. Combine the latestEvent base name with the application field of the EventInfo class.
  2. The field type of the application field is EntityInfo which is yet another info class, hence select the name field of the EntityInfo class.
  3. 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 NameDescriptionInfo Class
accountAccount in which the action was triggered.EntityInfo
policyPolicy that triggered the action.PolicyInfo
actionTriggered action.ActionInfo
topSeverityINFO, WARN or ERROR.NotificationSeverity
topSeverityImageSeverity image or icon.ImageInfo
notificationConfigTextEmail actions only.String
controllerUrlURL of the controller.String
appDynamicsIcon-ImageInfo
appDynamicsLogo-ImageInfo
latestEventMost recent triggering event.EventInfo
fullEventListList of events that triggered the action.List<EventInfo>
fullEventsByTypeMapList of events that triggered the action, grouped by type.Map<String, List<EventInfo>>
clampLimitOptional setting, limit on how many triggering events to display.
int
clampedTrue if clamp limit is set.boolean
clampedEventListn most recent triggering events if clamped.List<EventInfo>
clampedEventsByTypeMapn most recent triggering events if clamped, grouped by type.Map<String, List<EventInfo>>

fullEventsNodeMap

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;
}
CODE

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}
CODE


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
CODE

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 -->
#foreach(${events} in ${fullEventList}) 
#set($subject = ${events.eventType.toString()}) #end
...
CODE

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.
CODE

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>
CODE


Example code to list all variables:

#foreach($eventList in $fullEventsByTypeMap.values())
  #foreach($event in $eventList)
    || ${event.eventTime} | ${event.displayName} | ${event.severity} | $!{event.db.name} | $!{event.tier.name} | $!{event.node.name} | ${event.summaryMessage} ||
  #end
#end 
CODE

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.

Do not use any of the predefined variable names for your custom variables.