Skip to end of metadata
Go to start of metadata

This feature is planned for the next release of RHQ (4.13)

Creating empty alert definition

The following snippet will create an alert definition to resource 11293 with the name "empty alertDefinition". No other parameters are necessary to create one. Rest of the necessary values are filled with the same defaults as when used from the GUI.

Changing parameters

Pressing tabulator to auto-complete the emptyAlertDef will print the available functions.

function parameters
description
addCondition
AbstractCondition
Add new conditions that will trigger the alert
addNotification
AlertNotificationTemplate
Add new alert notification rule
alertProtocol
BooleanExpression
Match ALL or ANY of the conditions to fire an alert
dampening
AlertDampeningTemplate
Sets the dampening rules
description
String
Gives the alert definition a description
enabled
boolean
Disables or enables this alert definition (default is true)
name
String
Changes the name of the alert definition
priority
AlertPriority
Set the alerting priority (default is MEDIUM)
disableWhenFired
boolean
Disables the alert definition when it fires
recoverAlert
Integer
Enables alertDefinition that has been disabled

Setting dampening rules

Dampening rules can be accessed by creating new AlertDampeningTemplate() and then inserting that to AlertDefinitionTemplate() using dampening(AlertDampeningTemplate) command.

Notice that TimeUnits and Category are auto-completed incorrectly (see BZ 1155096). The correct syntax includes AlertDampening in the beginning of those enums.

Setting recovery settings

There are two options on the AlertDefinitionTemplate, "disableWhenFired (boolean)" and "recoverAlert (Integer)"

Adding conditions

Conditions are added by creating a new object that extends AbstractCondition and then using the addCondition(AbstractCondition) function on the AlertDefinitionTemplate. The list of available conditions is:

Class name Corresponding GUI term
AbsoluteValueCondition
Measurement Absolute Value Threshold
AvailabilityCondition
Availability Change
AvailabilityDurationCondition
Availability Duration
BaselineCondition
Measurement Baseline Threshold
ChangesCondition
Measurement Value Change
ControlCondition
Operation Execution
DriftCondition
Drift Detection
EventCondition
Event Detection
RangeCondition
Measurement Value Range
ResourceConfigurationCondition
Resource Configuration Change
TraitCondition
Trait Value Change

Example of adding new AbsoluteValue condition (with tabulator auto-complete showing the options):

Notification options

Creating notification with the generic API:

There are also pre-defined assist methods for included alert sender plugins:

Class name Equivalent senderPlugin
SystemUserNotifier
Alert:Subject
EmailNotifier
Alert:Email
CliNotifier
Alert:CLI
SnmpNotifier
 Alert:SNMP
 

An example to use SystemUserNotifier:

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.