TECHZEN Zenoss User Community ARCHIVE  

sending events with additional fields using the REST API

Subject: sending events with additional fields using the REST API
Author: [Not Specified]
Posted: 2015-05-01 09:18

Hello zenoss community,

I'm not sure if this is the right channel for this, but i would like to share a solution to a problem already mentioned in:
http://community.zenoss.org/message/74234

The problem is that zenoss v4/5 only allows a subset of fields to be sent as part of a request to create events. We make use of the message field quite often (to include things such as stack traces) so we need a way to include more information on events.

By changing two lines of code, it is possible to send any number of additional fields.

In Products/Zuul/routers/zep.py:

796c796
< def add_event(self, summary, device, component, severity, evclasskey, evclass=None):
---
> def add_event(self, summary, device, component, severity, evclasskey, evclass=None, **kwargs):
816c816
< self.zep.create(summary, severity, device, component, eventClassKey=evclasskey, eventClass=evclass)
---
> self.zep.create(summary, severity, device, component, eventClassKey=evclasskey, eventClass=evclass, **kwargs)

The additional **kwargs will allow you to send pretty much anything you want to zenoss, e.g.

curl -k -u 'admin:zenoss' -L -X POST -H 'Content-Type: application/json' -d '{"action":"EventsRouter","method":"newadd_event","data":[{"summary":"a large python","device":"test-device","component":"test-comp","severity":5,"evclasskey":"test-key","message":"unfeasibly large", ipAddress="1.2.3.4"}],"type":"rpc", "tid": "1"}' http://localhost:8080/zport/dmd/evconsole_router

I wonder if it is possible to get this patch into zenoss core



Subject: +1; this would be essential
Author: [Not Specified]
Posted: 2017-03-31 14:52

+1; this would be essential for us, and I'm concerned that the changes outlined in zep.py would take us out of support.



Subject: Part of the problem is that
Author: Jane Curry
Posted: 2017-04-11 05:45

Part of the problem is that the field in the MySQL events data base for message is defined as varchar(4096) so you can't expand the message attribute beyond that.

Cheers,

Jane

Email: jane.curry@skills-1st.co.uk    Web: https://www.skills-1st.co.uk



< Previous
Manipulate a data source before committed?
  Next
How to make fill-in graphs
>