Conditions

The condition and the clear condition are the part of the rule that determines which actions are executed.

When an agent is created, the condition associated with the rule is active and the clear condition is inactive. Time series data is collected every 5 seconds. Conditions and clear conditions—if any—are evaluated at each time series data collection point.

When the condition is active and transitions from false to true:

  • The rule actions, if any, are executed.

  • The condition becomes inactive.

    The condition does not become active again until the clear condition is true and becomes inactive.

  • The clear condition becomes active.

When the clear condition is active and transitions from false to true:

  • The clear actions, if any, are executed.

  • The clear condition becomes inactive.

  • The condition becomes active.

A condition can contain any number of monitors in its expression.

The following is an example of a condition in a rule:

# Monitoring average cpu value crossing 'minor_threshold' value that is set
    # over a given time interval
    self.r1.condition(
            '{} >= {}',
            [self.m1,
             self.params['minor_threshold']])
    self.r1.action(self.action_minor_avg_cpu)
    self.r1.clear_action(self.action_clear_minor_avg_cpu) 

The condition function contains the condition expression (in quotes) and, optionally, any parameters used in the condition expression.

In the example, the condition expression is relatively simple. The condition expression uses the >= operator to compare the current CPU value to the value of the minor_threshold parameter.

Condition and clear condition expressions can be complex and include aggregation functions, pauses and durations in monitoring, and support for time-series data.