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.
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.
event_classes: /Status/Acme: {}
Event Class Fields
The following fields are valid for an event class entry.
Name | Description | Required | Type | Default Value |
---|---|---|---|---|
path | Path to the Event Class (e.g. /Status/Acme). Must begin with “/”. | yes | string | (implied from key in event_classes map) |
description | Description of the event class. | no | string | "" (empty string) |
create | Should the event class be created when the ZenPack is installed | no | boolean | true |
remove | Should the event class be removed when the ZenPack is removed? This will only apply to a ZenPack that has created the event class. Any existing event classes not created by the ZenPack will not be removed. Any event classes created by the platform will also never be removed. | no | boolean | false |
reset | If true, any zProperties defined here will override those of the target event class. | no | boolean | false |
zProperties | zProperty values to set on the event class. | no | map<name, value> | {} (empty map) |
transform | A python block for transformation. | no | string (multiline) | "" (empty string) |
mappings | Event class mappings. | no | map<name, Event Class Mapping> | {} (empty map) |
Event Class Mapping Fields
The following fields are valid for an event class mapping entry.
Name | Description | Required | Type | Default Value |
---|---|---|---|---|
name | Name of the event class mapping (e.g. WidgetDown). | yes | string | (implied from key in mappings map) |
remove | Remove the Mapping when the ZenPack is removed. | no | boolean | false |
eventClassKey | Event class key matched by the mapping. | yes | string | None |
rule | A python expression to match an event. | no | string | "" (empty string) |
regex | A regular expression to match an event. | no | string | "" (empty string) |
example | Debugging string to use in the regular expression UI testing. | no | string (multiline) | "" (empty string) |
sequence | Define the match priority. Lower is a higher priority. | no | integer | 0 |
zProperties | zProperty values to set on the event class mapping. | no | map<name, value> | {} (empty map) |
transform | A python expression for transformation. | no | string (multiline) | "" (empty string) |
explanation | Textual description for matches of this event class mapping. Use in conjunction with the Resolution field. | no | string (multiline) | "" (empty string) |
resolution | Use the Resolution field to enter resolution instructions for clearing the event. | no | string (multiline) | "" (empty string) |