On this page:

Related pages:

Your Rating:
Results:
PatheticBadOKGoodOutstanding!
16 rates

This topic 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.

Forming 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, refer 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

These are the base names for the predefined variables with their corresponding info classes:

Base NameDescriptionInfo Class
accountAccount in which the action was triggeredEntityInfo
policyPolicy that triggered the actionPolicyInfo
actionTriggered actionActionInfo
topSeverityINFO, WARN or ERRORNotificationSeverity
topSeverityImageSeverity image or iconImageInfo
notificationConfigTextEmail actions onlyString
controllerUrlURL of the controllerString
appDynamicsIcon ImageInfo
appDynamicsLogo ImageInfo
latestEventMost recent triggering eventEventInfo
fullEventListList of events that triggered the actionList<EventInfo>
fullEventsByTypeMapList of events that triggered the action, grouped by typeMap<String, List<EventInfo>>
clampLimitOptional setting, limit on how many triggering events to display
int
clampedTrue if clamp limit is setboolean
clampedEventListn most recent triggering events if clampedList<EventInfo>
clampedEventsByTypeMapn most recent triggering events if clamped, grouped by typeMap<String, List<EventInfo>>

fullEventsNodeMap

Node level variables to be used in email and HTTP templates
Map<EventInfo, NodeTemplateVariables>

Info Class Fields

Use the fields in the appropriate class, based on the table above, 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
  List<EntityInfo> affectedEntities
  boolean healthRuleEvent
  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 PolicyInfo {
  EntityType entityType
  String entityTypeDisplayName
  long id
  String name
  boolean digest
  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;
}

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 right 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 the following 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

The following examples iterates 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 all your needs, you can define your own custom variables for use in these templates in the Create Template window.

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