Variables

In the rule language, certain variables are used to store event-related information across different event occurrences or rules. This event-related information can then be accessed from expressions within rules. Some types of variables are defined by the rule writer, and others are provided by the Active Correlation Technology. Some types can be accessed directly within an expression, and others can be accessed only through methods that are provided by the Active Correlation Technology.

Variables defined within <variable> elements and accessed through methods

You can define a variable within the <variable> element for a rule, rule block, or rule set. You can then access this variable within an expression by using one of the following methods:
  • The getVariable() method or one of the getjavatypeVariable() methods
  • The setVariable() method or one of the setjavatypeVariable() methods
For example, if you define the variable rule_writer_variable within the <variable> element for a rule, you can access this variable with the following code:
int sample_variable = act_lib.getIntVariable("rule_writer_variable");

Variables provided by the Active Correlation Technology and accessed directly within an expression

The following variables are provided by the Active Correlation Technology. You can use these variables inline within an expression.
  • act_event
  • act_eventList
  • act_lib
For example, with the following code, you can access the act_event variable to obtain the hostname attribute of an event:
act_event.getAttribute("hostname");

Variables provided by the Active Correlation Technology and accessed through methods

The following variables are provided by the Active Correlation Technology. You can access these variables within an expression by using the getVariable() method or one of the getjavatypeVariable() methods.
  • act_eventCount
  • act_location
  • act_nodeName
  • act_threshold
For example, with the following code, you can access the act_eventCount variable:
int eventcount_integer = act_lib.getIntVariable(IACTLibrary.EVENTCOUNT);
Table 1 shows the constants that the IACTLibrary interface provides for these variables. In your code, to ensure that any spelling or typographical errors are found during compilation rather than during run time, always use the constants that represent these variables rather than the variables themselves. For example, use act_lib.getIntVariable(IACTLibrary.EVENTCOUNT); rather than act_lib.getIntVariable("act_eventCount");.
Table 1. Variables with associated constants
Variable Associated constant
act_eventCount EVENTCOUNT
act_location LOCATION
act_nodeName NODENAME
act_threshold THRESHOLD
Related reference
variable element