Configuring Rule Violation Alerts and Actions
About this task
When a rule is violated, you can configure Optimize to do one or more of the following:
- Send e-mail alerts to specified users. If you subscribe to a pager or mobile phone service that supports text messaging to an e-mail address, you can also receive e-mail alerts on these devices.You can customize the body and subject line of e-mail alerts by creating custom alert templates.
- Send SNMP alerts to an SNMP manager.
- Invoke a Web service action.
Configuring E-mail Alerts
About this task
You can configure Optimize to notify interested parties by e-mail when rules are violated. Any defined user can be specified as the alert recipient when an alert is added to a rule in the Add/Edit/Copy Rule page (for more information, see IBM webMethods Optimize User’s Guide).
The My webMethods Define Environments page Mail Settings panel enables you to specify a custom alert e-mail template, in addition to configuring basic e-mail options as mail server settings and sender information. Unless you specify a custom template, Optimize uses a default template to format e-mail alerts.
For your custom template, you can create either a dynamic template that uses dynamic variable resolution to support more advanced formatting (preferred), or a static template that uses a fixed set of substitution variables (supported for compatibility with previous installations of Optimize).
Specifying E-mail Alert Settings and Templates
About this task
You can configure the settings for sending e-mail alerts from the My webMethods Define Environments page.
To configure settings for sending e-mail alerts
Procedure
Setting up E-mail Alert Templates to Use HTML Content
About this task
You can configure your e-mail alert templates to use HTML content.
To configure e-mail alert templates to use HTML content
Procedure
- Navigate to your e-mail alert templates folder (by default Optimize_directory/analysis/conf/templates).
- Open the e-mail template file for editing.
- Modify the [MIME] parameter value to text/html.
- Save your changes.
- Restart the Analytic Engine.
Creating a Dynamic Alert Template
Dynamic alert templates use the Velocity open-source templating framework. Using dynamic variable resolution, Velocity allows flexible generation of text and creation of templates using any context-related data elements instead of a fixed set of previously available variables. That is, instead of requiring that the variable ${rule.name} be explicitly defined, Velocity attempts to resolve the attribute “name” from the rule element within the context. If this variable cannot be resolved, the variable will appear verbatim in the generated e-mail, indicating that the substitution failed.
The Action Context
The context is an immutable representation of the rule's violation state. This context contains the following information related to the cause of the rule's violation:

An example substitution:
${rule.name}
This substitution causes Velocity to look up a property/entity located at the <root> of the context named rule, then within the <rule> entity, to locate a property named name. The process ends when the last element in the <property>.<property> sequence is resolved. If the element cannot be resolved, the substitution text remains in the output.
Producing a substitution for a template is a simple matter of determining the required information and navigating to it.
For example, if you want to output the start date of the diagnosis, you would first find the element you want (in this case, startDate of the diagnosis).

and then you would navigate backward to the root of the context.

Once you have the variable substitution configured, simply surround it within ${ } and use it within the template.
${diagnosis:startDate}
For further details on advanced formatting (looping, conditionals, etc.) refer to the Velocity documentation at http://velocity.apache.org/engine/devel/getting-started.html.
Example
The following example is the dynamic Velocity template for the default template used by Optimize to generate e-mail alerts. The [SUBJECT] and [BODY] tags denote the two currently supported sections of this template. Each section defines a separate Velocity template that uses the same action context.
[SUBJECT] $rule.instanceName
[BODY]
------------------------------------------------------------------
Rule Details:
Name: ${rule.name}
Instance name: ${rule.instanceName}
Description: ${rule.description}
Status: ${rule.status}
Severity: ${rule.severity}
Definition: ${rule.definition}
Evaluation: ${rule.evaluation}
URL: ${rule.URL}
Rule type: ${rule.ruleTypeString}
SLA: ${rule.sla}
Customer: ${rule.customer}
------------------------------------------------------------------
Diagnosis Details:
Start date: ${diagnosis.startDate}
End date: ${diagnosis.endDate}
Violation count: ${diagnosis.violationCount}
Violation id: ${diagnosis.violationId}
------------------------------------------------------------------
#foreach ($mapName in $context.getEvents().keySet())
#if ($rule.ruleTypeId == 1)
Event Details for Event Map: $mapName
#else
Event Details for KPI: $mapName
#end
#foreach ($event in $context.getEvents().get($mapName))
#if ($event.getDimensions().size() == 0)
Monitor dimensions: N/A
#else
Monitor dimensions:
#foreach ($dim in $event.dimensions)
$dim.dimensionName: $dim.dimensionValue
#end
#end
Attributes:
#foreach ($attrKey in $event.getAttributes().keySet())
#foreach ($attrValue in $event.getAttributes().get($attrKey))
$attrKey: $attrValue
#end
#end
#if ($event.getProcessInfo().size() > 0)
Number of Processes: $event.getProcessInfo().size()
#foreach ($procInfo in $event.processInfo)
#if ($procInfo.name)
Process info:
Name: $procInfo.name
Id: $procInfo.instanceExternalId
#if ($procInfo.stepName)
Step name: $procInfo.stepName
#end
URL: $procInfo.getURL()
#else
Process info: N/A
#end
#end
#end
#end
#end
------------------------------------------------------------------
For an example e-mail alert generated from this template, see IBM webMethods Optimize User’s Guide.
Creating a Static Custom Alert Template
You can also create an alert template using a simple text document with a fixed set of substitution variables. This document contains elements for the e-mail alert subject and body. You specify the format of the e-mail using a combination of plain text and substitution variables.
When an alert is formatted, the Analytic Engine attempts to retrieve the template associated with the rule in the Mail Settings panel (see Specifying E-mail Alert Settings and Templates). If a template is found, the alert is formatted using the specified template. If no template is specified, or the specified template is not found, the alert is formatted using the default template.
As the subject and body of the alert are formatted, any substitution variables contained in the template are expanded. When used initially, these templates are stored in the Analytic Engine to reduce the overhead associated with file loading. If the template file is modified, you must restart the Analytic Engine (see Starting Optimize) for the changes to take effect.
Example
The following is an example e-mail alert template. Note that the template is for a monitor alert. The substitution variables are explained in Specifying Substitution Variables.
Business Rule Violation - Template
---------------------------------------------------
[SUBJECT]
Rule: ${Rule.Name} ${Diagnosis.Attributes}
[BODY]
Rule Details:
Rule Name: ${Rule.Name}
Description: ${Rule.Description}
Date / Time: ${DateTime}
Rule Definition: ${Rule.Definition}
Rule Evaluation: ${Rule.Evaluation}
Rule SLA: $[Rule.sla]
Rule Customer: $[Rule.customer]
Rule Severity $[Rule.severity}
Rule Status ${Rule.status}
Out of Compliance: ${Violation.Count}
View Rule: ${Rule.URL}
Diagnosis Attributes:
${Diagnosis.Attributes}
Associated Text:
${Data}
Specifying Substitution Variables
About this task
You can use substitution variables to access the rule definition and diagnosis information. Variables also provide access to process information when an alert on a process event is triggered. These variables are case sensitive and must be specified exactly as defined below. If a variable cannot be found, the Analytic Engine will substitute a value of VARIABLE_NOT_FOUND in its place in the resulting e-mail alert.
Variable | Description |
---|---|
${Data} | An iteration of associated business or process data. |
${Data.<Field>} | The value of the associated data
named<Field> . See the
DISPLAY NAME
column of the Add/EditEvent Map page (Applications > Administration>
Analytics > KPIs > Business Data, and click the name of
the event map) for possible attributes to include. Results may vary depending
on rule expression settings and evaluation conditions. |
${DateTime} | The date and time of the rule violation. |
${Diagnosis.Attributes} | An iteration of rule diagnosis attributes. |
${Process.Event}* | The process event that triggered this alert. |
${Process.InstanceId}* | The process instance identifier. |
${Process.Name}* | The name of the process. |
${Process.StepName}* | The current step in the process. |
${Process.URL}* | The URL of the process instance in the user interface. |
${Rule.Definition} | The rule definition. |
${Rule.Description} | The description of the rule. |
${Rule.Evaluation} | The rule evaluation result. |
${Rule.Name} | The name of the rule. |
${Rule.URL} | The URL of the rule definition in the user interface. |
$[Rule.sla] | Whether the rule
is associated with a Service Level Agreement (SLA),
Yes or
No .
|
$[Rule.customer] | A customer name associated with the rule. |
$[Rule.severity} | The severity label assigned to the rule. |
${Rule.status} | The status of the
rule.
Rule Violated = rule is in violation. In Compliance = rule has gone back into compliance. |
${Violation.Count} | The number of times the rule is out of compliance. |
* Availability of the ${Process.*} substitution variables depends on the context of the rule you are accessing.
Examples:
- ${Process.Event}: To access this variable within a template, the rule must include the Error Type in the KPI or event rule definition. For example, a rule specified for the Intrinsic Process Metrics KPIs could be "Error Count by Process and Error Type" or "Error Count by Step and Error Type".
- ${Process.Step}: For this variable to be available, the KPIs or event rules must include the process step dimension.
If the variable cannot be substituted, a message indicating the problem is displayed in place of these variables.
Configuring SNMP Alerts
About this task
Typically, Optimize sends alerts about rule violations by e-mail. Alternatively, you can configure Optimize to send alerts using SNMP. With SNMP alerts, when a rule is violated the Analytic Engine sends the SNMP alert to the SNMP manager associated with the rule.
The Analytic Engine sends the SNMP alert named webMethodsAlert as an enterprise-specific alert consisting of two OCTET string type variables, one containing the name of the rule that was violated and one containing the monitor ID. The SNMP manager can retrieve the subject and body strings according to the structure defined in the Optimize Management Information Base (MIB) file WEBMETHODS-COMMON-MIB.txt, located in the Optimize_directory\analysis\conf\MIB directory.
You configure SNMP settings through the My webMethods Define environments page.
To configure settings for sending SNMP alerts
Procedure
Configuring Web Service Actions
For information on configuring Web service actions, see Configuring Web Services Actions.