Using Ad Hoc Alert Sources
Ad hoc alerts are raised by the System_Alert_Send process definition or by custom script using RedwoodScript. The process definition or code can be placed into chain definition in order to implement customized alerting.
The process takes two parameters:
- The name of the ad hoc alert source
- An optional Data parameter that can be used to determine the escalation to use. This is available as a substitution parameter in the alert source expressions and the alert source email body.
Substitution Parameters
The following list contains popular substitution parameters used in ad hoc alert sources:
${jobId}
- the ID of the alerting process.${data}
- the value of the data parameter to the alerting process.${topLevelJobId}
- the ID of the main parent of the chain (outer-most chain definition)${chainJobId}
- the ID of the parent of the chain (inner-most chain definition)
See Scripting Contexts and Implicit Objects for a full list.
Operator message and reply expressions
The operator message to use is specified as an expression that allows substitution parameters. The message can be specified only at the alert source level. If no message is specified, the default message is Acknowledge.
The reply expression works the same way as the reply expression for the System_OperatorMessage process, it can be written as a regular expression. This can be specified at the alert source level. If no reply expression is specified, the default reply expression is Acknowledge.
Escalation
Escalations send operator messages and emails (via Email Alert Gateways). When a specific condition does not have an escalation, no operator message is sent and the condition is ignored.
When nobody has resolved the alert in a timely fashion, you can escalate the alert to another operator, this is done with escalations.
Ad hoc alert sources use two rules to determine the alert escalation to use:
- An expression to determine a dynamic escalation name. This expression supports ${substitution parameter} substitutions and the REL syntax for expressions.
- A default alert escalation
The expression is always evaluated first. If the escalation returned by the expression exists, then it is used. If it does not exist, then the default is used. This allows the escalation used to be dynamic.
Alert Source Actions
Alert source actions are used to customize the behavior using RedwoodScript.
Customizing Alert Emails
You can customize emails on the Alert Source Email tab, using the following two constructs:
- conditional evaluation
- REL expressions (without the equals (
=
))
Conditional Evaluation
[?if test="expression"?]
text
[?endif?]
REL Expressions
[?=expression?]
Example
<html>
<head><title>Email</title></head>
<body>
Ad-hoc alert: [?=data?]
[?if test="String.indexOf(data, 'important') > -1"?]
Attention, please, this one is important: ${data}
Time now is: [?=Time.now('Europe/London')?]
[?endif?]
Link <a
href="https://prd1.example.com/redwood/api-permalink/show?link-objecttype=[?=alertSourceType?]&link-uniqueid=[?=alertSourceUniqueId?]">alert source</a>
</body>
</html>
Procedure
Use the finance
escalation when the System_Alert_Send process is run with DataWareHouseLoaded as the value of the Alert Source parameter.
- Navigate to "Alerting > Ad Hoc Alert Sources".
- Choose New Ad Hoc Alert Source from the context-menu.
- Fill
DataWareHouseLoaded
into the Name andFinance
into the Default Alert Escalation fields. - Choose Save & Close.
note
This requires the following alert escalations Finance
.
Make the escalation dependent on the value of the Data parameter
- Navigate to "Alerting > Ad Hoc Alert Sources".
- Choose New Ad Hoc Alert Source from the context-menu.
- Fill
DataMartReadCompleted
into the Name,DataMart_${data}
into the Escalation Expression andDataMart_Default
into the Default Alert Escalation fields. - Choose Save & Close.
Result
The second procedure uses an escalation expression:
When the System_Alert_Send process definition is run with DataWareHouseReadCompleted as alert source parameter, then the escalation run depends on the value of the Data parameter:
- data is USA - escalation DataMart_USA is run
- data is EMEA - escalation DataMart_EMEA is run
- data is APJ - escalation DataMart_APJ is run
- data is India - escalation DataMart_Default is run
- data is China - escalation DataMart_Default is run
Example
Restart the inner-most chain when an ad hoc alert is sent
{
// Get the alert information
Alert alert = jcsAlertSourcePostAlertContext.getAlert();
OperatorMessage oMessage = alert.getOperatorMessage();
SchedulerEntity sEntity = oMessage.getSenderObject();
// Restart parent of parent
Job process = (Job) sEntity;
process.getParentJob().getParentJob().resubmit();
}
AdHocAlertSource AlertSource AlertSourceAction