10.3. Classes and Functions¶
10.3.1. Alert¶
-
class
net.happygears.nw2.alerts.
Alert
¶ Function
nw2functions.alert()
returns list of instances of the classAlert
. You can ignore them in your normal Python rules script but it can be useful to check their fields in unit tests. See Examples of Unit Tests for some examples. Here we provide description of the attributes and functions of objects of this class.See also
10.3.1.1. Attributes¶
streams
¶List of strings: names of the notification streams this alert is configured with
name
¶Name of this alert
deviceName
¶The name of the device taken from the input monitorign variable
deviceId
¶Device id taken from the input monitoring variable
componentName
¶Component name (or interface name) from the input monitoring variable
componentIndex
¶Component index (or interface ifIndex) from the input monitoring variable
value
¶Input monitoring variable value that triggered the alert. Note that if the call to
nw2functions.alert()
specifies non-zero time interval and percentage, then this field is filled with the value of the last matching observation in the input variable time series.
description
¶Alert description with all macros expanded.
details
¶A dictionary that provides additional details for the alert, with all macros expanded. More information is provided in the description of function
nw2functions.alert()
Tags copied from the input monitoring variable instance that triggered the alert (set of strings)
variable
¶The triplet (handle) of the alert monitoring variable. This is composed from the alert name, device id and component index.
inputVariable
¶The triplet (handle) of the input monitoring variable that triggered the alert. Note that this only makes sence and is filled with a non-empty string if the alert is configured to fan-out, in which case the call to
nw2functions.alert()
creates separate Alert object for each matching instance of the input monitoring variable. However if the call tonw2functions.alert()
used temporary variable as input, this field is going to be blank.This field is always blank in the non-fan out alerts.
activeSince
¶The time stamp (ms) of the moment when this alert changed its state from “Cleared” to “Active”
activeSinceStr
¶The same time, converted to string, taking into account time zone configured in the main configuration file.
active
¶(boolean), true if the alert is active right now
silenced
¶(boolean), true if the alert matches any silence(s) that exist in the system. Alert can be active and silenced at the same time
matchingSilenceId
¶The id of the silence matching this alert (only if field silenced has value true)
updatedAt
¶the time stamp (ms) when alert was updated last time
toJson
(indent)¶Call this method to get this alert in JSON format. This is useful in unit tests to verify alert fields. See Test Alert and its Fields