Callback actions

Callback actions are callback functions that call other Python methods in the script to perform further processing. Callback actions can also call predefined actions and functions that have been imported from the supported Python modules or third-party libraries.

Callback actions are executed when the condition of a rule is true. If a callback action calls a predefined action, that predefined action is executed asynchronously. Callback actions time out after five minutes. This timeout interval is not editable.

This example contains a callback action, action_high_poll_interval, that calls the predefined actions ActionSyslog and ActionCLI:


        uri = '/rest/v1/system?attributes=resource_utilization_poll_interval'
        self.m = Monitor(uri, name='My Monitor')
        self.r = Rule('Resource Utilization Poll Interval')
        self.r.condition('{} > 100 for 30 seconds', [self.m])
        self.r.action(self.action_high_poll_interval)

    def action_high_poll_interval(self, event):
        self.set_alert_level(AlertLevel.CRITICAL)
        ActionSyslog('High Poll Interval')
        ActionCLI("show running-config")

Aruba Network Analytics Engine agent sandboxes run in the default VRF. If a script has a function that requires access to the Internet, this function fails unless the switch administrator configures a DNS name server on the default VRF.

When a condition is met, an event is generated and the callback action is executed using the event details. The event parameter passed to the callback action contains those event details.

The event parameter contains a dictionary of key-value pairs. The dictionary includes the following keys:

event['labels']

The labels created by the time-series database.

event['condition_name']

The name of the condition that triggers the event.

event['monitor_name']

The name of the monitor.

event['time_series']

The name of the time series metric.

event['value']

The value of the time series metric.

event['timestamp']

The timestamp of the generated event.

event['condition_description']

The description of the condition that triggered the event.