ZenPacks, JSON API, and Integrations

Expand all | Collapse all

Create multiple events from single event.

  • 1.  Create multiple events from single event.

    Posted 09-19-2019 04:00 PM
    Edited by Morgan Timney 09-20-2019 07:59 AM
    I have a single 'parent' event that contains encoded data that indicates the state of over 50 components. What I am trying to do is to create one or more events from in the 'parent' events transform.

    I am thinking that I will need to use the EventsRouter? But to use it from within Zenoss (instead of an external API call)? Something like this - but perhaps with imports first?

    zenoss_api.evconsole_router.EventsRouter.add_event('{"summary":"Component x is down","device":evt.device,"component":"x","severity":"Error","evclasskey":"$evkey","evclass":"$evclass"}')
    This will be an interim solution until I create a zenpack around these components.

    ------------------------------
    Morgan Timney
    The Southern Company
    Birmingham AL
    ------------------------------


  • 2.  RE: Create multiple events from single event.

    Posted 14 days ago
    ¯\_(ツ)_/¯   ... when you google something and find yourself asking the same question a year earlier.

    ------------------------------
    Morgan Timney
    The Southern Company
    Birmingham AL
    ------------------------------



  • 3.  RE: Create multiple events from single event.

    Posted 13 days ago
    Hey, Morgan!

    In your original post, you mentioned doing this in a transform instead of externally?  I'm going to recommend going the external route.  If your transform is taking the field of components from the parent event, then generating between 1-50 child events, every event in the pipeline behind the parent event has to wait for the transform to complete.  If zeneventserver is slow to respond to the API calls creating the children, then everyone in line just gets to wait longer.

    Instead, I recommend the following:

    1. Build a command notification along the lines of ssh user@automationhost 'yourEventScript ${evt/evid}'
    2. Build yourEventScript to:
        a. take an event ID as an argument.
        b. make an event router call to look up the parent event by its ID.
        c. break out the list of components from the parent ID to form a list.
        d. run a loop using the list to create the child events

    Now, you can build your error handling / timeouts / retries into your API script without fear of borking the event pipeline.  It may not be as elegant as a single transform that does it all automagically, but it's far safer and easier to extend for future use cases.

    I hope that helps!

    ------------------------------
    Michael J. Rogers
    Senior Instructor - Zenoss
    Austin TX
    ------------------------------