TECHZEN Zenoss User Community ARCHIVE  

Create multiple events from single event.

Subject: Create multiple events from single event.
Author: Morgan Timney
Posted: 2019-09-19 17:00

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
------------------------------


Subject: RE: Create multiple events from single event.
Author: Morgan Timney
Posted: 2020-10-09 14:16

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

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


Subject: RE: Create multiple events from single event.
Author: Michael Rogers
Posted: 2020-10-09 22:06

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
------------------------------


< Previous
run_command API output in plain text instead of HTML
  Next
Latest API doc
>