Classes and Functions ===================== Alert ----- .. class:: net.happygears.nw2.alerts.Alert Function :py:func:`nw2functions.alert()` returns list of instances of the class :py:class:`Alert`. You can ignore them in your normal Python rules script but it can be useful to check their fields in unit tests. See :ref:`examples_of_tests` for some examples. Here we provide description of the attributes and functions of objects of this class. .. seealso:: :py:func:`nw2functions.alert()` Attributes ^^^^^^^^^^ .. py:attribute:: streams List of strings: names of the notification streams this alert is configured with .. py:attribute:: name Name of this alert .. py:attribute:: deviceName The name of the device taken from the input monitorign variable .. py:attribute:: deviceId Device id taken from the input monitoring variable .. py:attribute:: componentName Component name (or interface name) from the input monitoring variable .. py:attribute:: componentIndex Component index (or interface ifIndex) from the input monitoring variable .. py:attribute:: value Input monitoring variable value that triggered the alert. Note that if the call to :py:func:`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. .. py:attribute:: description Alert description with all macros expanded. .. py:attribute:: details A dictionary that provides additional details for the alert, with all macros expanded. More information is provided in the description of function :py:func:`nw2functions.alert()` .. py:attribute:: tags Tags copied from the input monitoring variable instance that triggered the alert (set of strings) .. py:attribute:: variable The triplet (handle) of the alert monitoring variable. This is composed from the alert name, device id and component index. .. py:attribute:: 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 :py:func:`nw2functions.alert()` creates separate `Alert` object for each matching instance of the input monitoring variable. However if the call to :py:func:`nw2functions.alert()` used temporary variable as input, this field is going to be blank. This field is always blank in the non-fan out alerts. .. py:attribute:: activeSince The time stamp (ms) of the moment when this alert changed its state from "Cleared" to "Active" .. py:attribute:: activeSinceStr The same time, converted to string, taking into account time zone configured in the main configuration file. .. py:attribute:: active (boolean), true if the alert is active right now .. py:attribute:: 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 .. py:attribute:: matchingSilenceId The id of the silence matching this alert (only if field `silenced` has value true) .. py:attribute:: updatedAt the time stamp (ms) when alert was updated last time .. py:method:: toJson(indent) Call this method to get this alert in JSON format. This is useful in unit tests to verify alert fields. See :ref:`unit_test_alert_1`