Skip to content

Event classes

Event Classes are used to group together specific types of events. This can be useful for situations where an event should be dropped or text should be altered to be more human readable. This is typically done through a python transform.

To define a class, supply the path to the class or classes. Then, for each event class, supply the appropriate properties for the class. These include the option to remove the event class during ZenPack installation/uninstallation, description, and a transform. You can also define mappings to apply to events based on a key and supply an explanation and/or resolution to an issue.

When you define an event class and/or mapping which already exists, any settings defined in your ZenPack will overwrite existing settings.

The following example shows an example of a zenpack.yaml file with an example of a definition of an event class.

zenpack.yaml
name: ZenPacks.acme.Events

event_classes:
  /Status/Acme:
    remove: false
    description: Acme event class
    mappings:
      Widget:
        eventClassKey: WidgetEvent
        sequence:  10
        remove: true
        transform: |-
          if evt.message.find('Error reading value for') >= 0:
              evt._action = 'drop'

When assigning values to multi-line fields such as transform or example, the best way to preserve whitespace and readability is to use YAML's |- multiline indicator as shown above.

Since this is a YAML mapping, the minimal specification (name only) would look like the following example.

zenpack.yaml
event_classes:
  /Status/Acme: {}

Event class fields

The following fields are valid for an event class entry.

path (required, string, default = implied from key in event_classes map)
Path to the Event Class (e.g. /Status/Acme). Must begin with the solidus character (/).
description (optional, string, default = "" (empty string))
Description of the event class.
create (optional, boolean, default = true)
Should the event class be created when the ZenPack is installed.
remove (optional, boolean, default = false)

Should the event class be removed when the ZenPack is removed?

This only applies to the ZenPack that created the event class. - Event classes not created by the ZenPack are not removed. - Event classes created by the platform are never removed.

reset (optional, boolean, default = false)
If true, any zProperties defined here will override those of the target event class.
zProperties (optional, map, {} (empty map))
zProperty values to set on the event class.
transform (optional, string (multiline), default = "" (empty string))
A python block for transformation.
mappings (optional, map, {} (empty map))
Event class mappings.

Event Class Mapping Fields

The following fields are valid for an event class mapping entry.

name (required, string, default = implied from key in mappings map)
Name of the event class mapping (e.g. WidgetDown).
remove (optional, boolean, default = false)
Remove the mapping when the ZenPack is removed?
eventClassKey (optional, string, default = None)
Event class key matched by the mapping.
rule (optional, string, default = "" (empty string))
A python expression to match an event.
regex (optional, string, default = "" (empty string))
A regular expression to match an event.
example (optional, string (multiline), default = "" (empty string))
Debugging string to use in the regular expression UI testing.
sequence (optional, integer, default = 0)
Define the match priority. Lower is a higher priority.
zProperties (optional, map, {} (empty map))
zProperty values to set on the event class mapping.
transform (optional, string (multiline), default = "" (empty string))
A Python expression for transformation.
explanation (optional, string (multiline), default = "" (empty string))
Textual description for matches of this event class mapping. Use in conjunction with the Resolution field.
resolution (optional, string (multiline), default = "" (empty string))
Use the Resolution field to enter resolution instructions for clearing the event.