zenoss / ZenPacks.zenoss.ZenPackLib

This is a helper library for zenpacks.
http://zenpacklib.zenoss.com/
GNU General Public License v2.0
15 stars 17 forks source link

Helpful document update to Transforms #453

Open iwills opened 7 years ago

iwills commented 7 years ago

In the ZenPackLib example, it shows a transform written as follows:

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:\n\
          \   evt._action = 'drop'"

For longer transforms, you can use the following format, which is way easier than having to wrap everything in " and including \n and \, because you can just cut and paste code and adjust indenting to match the level of the "transform" key + one level of indent, i.e.:

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'

Hope that helps someone.