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

  1. In My webMethods, navigate the following path: Applications > Administration > System-Wide > Environments> Define Environments.
  2. Click the name of the configured environment for which you want to configure e-mail alert settings.
  3. Click the Configure Servers tab.
  4. On the CONFIGURATION tree, find the Analytic Engine for which you want to configure mail alert settings, and click Mail Settings under the name of the Analytic Engine. The Analytic Engine Mail Settings panel is displayed.
  5. The following table provides information about the Mail Settings.
    Attribute Definition
    Mail Server Name of the host system on which the SMTP server resides that sends e-mail containing alerts. For example, this server might be smtp.client.com.
    Note: Optimize does not support SMTP servers that require authentication.
    Sender Domain E-mail domain for the e-mail address specified in the Default Sender field (such as webmethods.com).
    Default Sender Sender to specify in the From field of the alert e-mails. Make sure the e-mail address provided in this field is within the e-mail domain specified in the Sender Domain field.
    Admin Address E-mail address of the recipient that you want to receive copies of e-mail alerts. The e-mail address in this field is also used as the default address for sending test e-mail messages from the System Settings page (Applications > Administration > My webMethods > System Settings).
    Default Mail Encoding Default encoding to use for e-mail that is sent to users. You can specify any MIME registered encoding name. The default value is UTF-8. You can specify a different encoding for individual users on the Edit User page. For information on configuring user profiles, see Working with IBM My webMethods.
    Templates Used to specify custom e-mail alert templates.

    Syntax: <rule name> = <template name>

    • Dynamic custom alert template filenames must end with the .vm extension.
    • Static custom alert template filenames typically end with the.template extension.

    When the specified rule is violated, the e-mail alert is formatted based on the associated alert template. First it searches for a template configured with the rule's instance name. If one is not found, it searches for a template configured with the base rule. If no specified templates are found, the Analytic Engine uses the default format for the e-mail alert.

    For example, in the Mail Settings panel above, the template attribute specifies that when the rule named Business monitor violation is triggered, the Analytic Engine uses the static custom alert template named BusinessMonitorViolation.template that is in the default templates directory ( Optimize_directory/analysis/conf/templates):

    Business monitor violation=                      
    ./templates/BusinessMonitorViolation.template

    You can also configure your e-mail alert template to use HTML content. For more information, see Setting up E-mail Alert Templates to Use HTML Content.

    Socket Timeout The amount of time in seconds before the Analytic Engine terminates an idle connection with the SMTP server. The default value is 60.
  6. Click Save.
  7. Click Finish.
  8. Put the changes into effect. See Changing Your Configuration Settings.

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

  1. Navigate to your e-mail alert templates folder (by default Optimize_directory/analysis/conf/templates).
  2. Open the e-mail template file for editing.
  3. Modify the [MIME] parameter value to text/html.
  4. Save your changes.
  5. 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:

Action context

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

The start date of the diagnosis element

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

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.

Important: A dynamic custom alert template file must end with a .vm extension for the template to be recognized and processed correctly. See Specifying E-mail Alert Settings and Templates for instructions on specifying a custom template.

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.

The following table provides information about the substitution variables.
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

  1. In My webMethods, navigate the following path: Applications > Administration > System-Wide > Environments> Define Environments.
  2. Click the name of the configured environment for which you want to <task>.
  3. Click the Configure Servers tab.
  4. On the CONFIGURATION tree, find the Analytic Engine for which you want to configure SNMP alert settings, and click SNMP Alert Settings under the name of the Analytic Engine.

    The SNMP Alert Settings page is displayed.

  5. Identify the SNMP manager to receive the alert by uncommenting and editing this XML:
    <properties> 
    <!-- (Remove this line to uncomment the file.) 
    <property name="SNMPManager"> 
    <string meta="managerName">SNMP_Manager_Host1</sting> 
    <string meta="host">host1</string> 
    <integer meta="port">161</integer> 
    <property name="community">                         
    <string meta="handle">passwordHandle</string> 
    <string meta="password">password</string> 
    </property> 
    </property> 
    --> (Remove this line to uncomment the file.) 
    </properties>
    The following table provides information about the SNMP alert settings.
    For Substitute the
    SNMP_Manager_Host1 Name of the SNMP manager you want to receive alerts. This value is a symbolic name and can be any string denoting the SNMP manager host.

    This name also appears on the Rule Editor page when configuring the SNMP alert.

    host1 Actual host name of the SNMP manager to receive the alert. Do not specify localhost; you must use the host name or IP address of the SNMP manager.
    161 Port number of the SNMP manager to receive the alert.
    passwordHandle Handle used for identifying the password specified in the password string. Use SNMPCommunityHandle if you will only specify one password for SNMP Alert settings, or specify a unique handle for each password if multiple passwords will be used.
    password Specify a password. Must be accompanied by a user name. Once this settings file is saved and processed, the password is encrypted, and it is displayed only as asterisks.

    If a substitution cannot be made, use an empty string instead.

    Optimize displays the SNMP managers you identified in the SNMP Alert Settings panel on the Edit Rule page. For more information about selecting an SNMP manager on this page, see IBM webMethods Optimize User’s Guide.

  6. If you want to identify more than one SNMP manager to receive alerts, copy and edit the XML shown in step 5 for each SNMP manager.
  7. Click Save.
  8. Apply the changes by re-deploying your environment (see Changing Your Configuration Settings) and restarting the Analytic Engine as described in Starting Optimize.
  9. Make sure the new settings work, as follows:
    1. In My webMethods, navigate the following path: Applications > Administration > Analytics > Rules > Rule List.
    2. On the Rule List page, click Create Rule.
    3. In the Actions area on the Edit Rule page, click Add Action.Ensure that the Action Name list contains the SNMP managers you added to the SNMP Alert Settings panel.

      If the Action Name list does not contain the SNMP managers you identified, check the syntax of the XML in the SNMP Alert Settings panel.