Working with Job Alert Sources
You can use Job Alert Sources to generate an alert when a Job or Workflow reaches a particular status. You can even configure a Job Alert Source to generate separate alerts for separate statuses.
Every Job Alert Source must specify at least a Name Pattern and one target status. All specified conditions must be met for an alert to fire.
Creating a Job Alert Source
To create a new Job Alert Source:
- Navigate to Configure > Control > Alerting > Job Alert Sources.
- Click New.
- Enter a Name for the Job Alert Source.
- In the Name Pattern field, enter a pattern matching the name of all Jobs you want to raise alerts for. You can use a variety of different syntaxes to define the pattern. Choose the one you want from the Name Match Type dropdown list.
- Click the Statuses tab.
- For each status you want to raise an alert on:
- Click
and select a status from the Status dropdown list.
- If desired, enter a Delay Amount and choose an option from Delay Units.
- Optionally enter a status-specific Operator Message to override the default message.
- Click
- To verify that the Alert Source does what you want it to, click the Preview tab.
- Click Save & Close.
Tabs and Fields
Note: For tabs and fields that are common to all objects, see Object Tabs.
Tab | Field | Description |
---|---|---|
Job Alert Source | Name Pattern |
A name pattern to match Job Definition names. |
Job Alert Source | Name Match Type | A type of syntax for matching. Options include Exact Case Insensitive, Exact Case Sensitive, Glob Case Insensitive, Glob Case Sensitive, RegEx Case Insensitive, and RegEx Case Insensitive. |
Job Alert Source | Partition Pattern |
A name pattern to match Partition names. |
Job Alert Source | Partition Match Type | A type of syntax for matching. Options include Exact Case Insensitive, Exact Case Sensitive, Glob Case Insensitive, Glob Case Sensitive, RegEx Case Insensitive, and RegEx Case Insensitive. |
Job Alert Source | Alert on Restart |
Lets you avoid creating a separate Alert every time a Job is forced to restart. Choose an option other than [None], or All restarts to limit Alerts to being sent after a specific number of restarts. |
Job Alert Source | Time Window Status | Lets you specify whether to fire Alerts when the Time Window selected in the Time Window field is open or closed. |
Job Alert Source | Time Window | Lets you specify that Alerts should only be fired when a particular Time Window is open or closed (depending on the value in the Time Window Status field). |
Job Alert Source | Time Zone | The time zone for the selected Time Window. |
Job Alert Source | Operator Message Expression | A custom Operator Message expression. This field allows substitution parameters. |
Job Alert Source | Operator Message Reply Expression | A custom Operator Message reply expression. You can use regular expressions in the reply expression to force the user to select a reply option. If no reply expression is specified, the default reply expression is Acknowledge. This field allows substitution parameters. |
Job Alert Source | Address |
The email address or addresses to which the Alert should be sent, separated by semicolons (no spaces). Each email address can use substitution parameters and is resolved by an Email Alert Gateway. The alert will be sent to the specified address and escalated, if necessary, using the specified escalation. Note: All email addresses must match the Address Pattern on the Email Alert Gateway. |
Job Alert Source | Default Alert Escalation | The default escalation to use. |
Job Alert Source | Escalation Expression |
If you do not provide a Default Alert Escalation, you must specify an Escalation Expression. Note: The Escalation Expression field is evaluated before the Default Alert Escalation field. If the Escalation Expression field results in a match, the Default Alert Escalation is ignored. |
Statuses | Workflow definition alerts on |
This dropdown list lets you specify how alerts are handled in Workflow Definitions. When you choose an option from this list, the user interface explains how the option works. For more information, see Status Matching and Workflows. Note: If the Job Alert Source is only supposed to match Job Definitions that are not part of a Workflow Definition, this field is ignored. |
Statuses | Status | The status to alert on. |
Statuses | Delay Amount | The number of Delay Units to wait until the Alert is sent. The system will only raise the Alert if the Job is still in the status mentioned after the specified delay. This is important for transient Job statuses such as Waiting, EventWait or Queued. It is not necessary for final statuses such as Error, Killed, or Completed. |
Statuses | Delay Units | The units of time used in the Delay Amount. |
Statuses | Operator Message Expression | A status-specific Operator Message expression. If you specify this, it overrides the default Operator Message expression for this Job Alert Source. |
Parameter Matches | Name | The name of the Parameter to match. |
Parameter Matches | Value | The Parameter value to match. |
Parameter Matches | Match Type | A type of syntax for matching. Options include Exact Case Insensitive, Exact Case Sensitive, Glob Case Insensitive, Glob Case Sensitive, RegEx Case Insensitive, and RegEx Case Insensitive. |
Rules | Processing Order | The order in which the rule is processed. |
Rules | Variable | The property evaluated by the rule. Options include Priority, Job Server, Queue, Remote Event, Remote Id, Remote Status, Remote System, and Return Code. |
Rules | Operation | The operator use to compare the value of the Variable. |
Rules | Value | The expected value of the Variable using the Operation. |
Rules | Alert Escalation | Lets you specify a rule-specific escalation. If you specify an option, this overrides the Alert Source's default escalation. |
Alert Source Email | Body | The body of the email to send. For information on customizing this field, see Customizing Alert Emails. |
Actions | Type | The type of action to take when an Alert needs to be fired. The only valid option for Alert Sources is Post Alert. Any action you define here will be executed after the Alert is sent. You must reply to the Operator Message and delete it if you want to suppress it. |
Actions | Enabled | Lets you enable or disable the action. |
Actions | Action Subject | The user under which the code in the action is performed. You must set this if you want to use jcsSession . |
Actions | Library | Lets you specify a library containing methods you want to use in the Source field. |
Actions | Source | The source code of the script. |
Security
The privileges available in the Security tab are as follows.
For more information, see Security Tab.
Privilege | Description |
---|---|
JobDefinitionAlertSource.Create | Create Workflow Alert Sources |
JobDefinitionAlertSource.Delete | Delete Workflow Alert Sources |
JobDefinitionAlertSource.Edit | Edit Workflow Alert Sources |
JobDefinitionAlertSource.View | Access Workflow Alert Sources |
Status Matching and Workflows
The following alerting options are available for Workflows:
- Workflow and Steps: The alert fires for Job Calls and Workflows that match the name pattern and have reached the target status.
- Workflow and Steps: The alert fires for Steps and Workflows that match the name pattern and have reached the target status.
- Workflow Only: The alert fires for Workflows that match the name pattern and have reached the target status.
- Workflow, Steps, And Processes: The alert fires for Job Calls, Steps, and Workflows that match the name pattern and have reached the target status.
- Processes Only: The alert fires for Job Calls that match the name pattern and have reached the target status.
- Standard: The alert fires for Workflows that match the name pattern and have reached the target status. The alert also fires for steps that have reached statuses Console or Console Restart.
- Steps And Processes: The alert fires for Job Calls and Steps that match the name pattern and have reached the target status.
- Steps Only: The alert fires for Steps that match the name pattern and have reached the target status.
Alerts can be generated for any combination of types (single Jobs, Workflows, Steps, and Job Calls). The status of a Job Call or Step is escalated up to the Workflow, so it's important to pay special attention when you want to raise an alert on a Workflow. Incorrectly configured Alert Sources can fire duplicate Alerts.
The Standard behavior is to match only Workflows (or, for Steps, statuses Console and Console Restart). This means that if you use On Error Status Handlers in Workflows in combination with the Standard behavior, you must make sure the Workflow reaches status Error when an error occurs (or that one of the steps reaches status Console or Console Restart). In this case, you should specify status rules for Console and Console Restart in combination with a Request Restart Status Handler. The Workflow Partition and name are used for matching; the Partitions and names of the Job Definitions called within the Workflow (Job Calls) are not taken into account.
Example Job Alert Sources
The following example shows how to generate an alert if any SAP_AbapRun
Job enters status Error, Unknown, Killed, or Canceled.
- Navigate to Configure > Control > Alerting > Job Alert Sources.
- Click New.
- In the Name Pattern field, enter
SAP_AbapRun*
. - In the Operator Message Expression field, enter
Job ${jobOwner}.${jobDefinition} with ID ${jobId} reached status ${newStatus}. Has the Job been restarted?
. - In the Operator Message Reply Expression field, enter
^Yes|No$
. This will force users to reply with Yes or No. - On the Statuses tab, add a row and choose select Error from the Status dropdown list. Repeat this step for statuses Unknown, Killed, and Canceled.
- Click Save & Close.
The following example generates an alert if any SAP_AbapRun
Job where the parameter SAP_SYSTEMS
has value ERP
enters status Error, Unknown, Killed, or Canceled. Note that for the Operator Message to work, the Job Definition must have a parameter named Param1
.
- Navigate to Configure > Control > Alerting > Job Alert Sources.
- Click New.
- In the Name Pattern field, enter
SAP_AbapRun*
. - In the Operator Message Expression field, enter
='Job ${jobOwner}.${jobDefinition} with ID ${jobId} and Parameter '+parameters.Param1+'reached status ${newStatus}!'
. - On the Statuses tab, add a row and choose select Error from the Status dropdown list. Repeat this step for statuses Unknown, Killed, and Canceled.
- On the Parameter Matches tab, click Add, then enter
SAP_SYSTEMS
in the Name field andERP
in the Value field. - Click Save & Close.
The following sample Source could be used in a Post Alert action. Assume that a Job is configured to restart if it reaches status Error, and its maximum number of restarts is set to 4. Assume further that you do not want to have to answer an alert for the first restart. Note that getRestartCount
returns the number of remaining restarts.
{
// Get the alert information
Alert alert = jcsAlertSourcePostAlertContext.getAlert();
OperatorMessage omessage = alert.getOperatorMessage();
SchedulerEntity sentity = omessage.getSenderObject();
// Do not send emails for the first failure
if (sentity instanceof Job)
{
Job Process = (Job) sentity;
Long restartCount = new Long(3L);
// If RestartJobId is null, then this is the first Process.
if (Process.getStatus().getState() == JobStatusState.Final && restartCount.equals(Process.getRestartCount()))
{
// Reply to the Operator Message and restart the job
omessage.setReply("Acknowledged");
}
}
}