sending events with additional fields using the REST API

3 posts / 0 new
Last post
Superfan
Superfan's picture
Offline
Last seen: 1 year 12 months ago
Joined: 05/01/2015 - 08:53
Posts: 1
sending events with additional fields using the REST API

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?

Tags: 
Niall.munnelly
Niall.munnelly's picture
Offline
Last seen: 4 weeks 1 hour ago
Joined: 10/27/2016 - 14:14
Posts: 3
+1; this would be essential

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

Jcurry
Jcurry's picture
Offline
Last seen: 3 days 7 hours ago
Joined: 01/02/2014 - 13:04
Posts: 407
Part of the problem is that

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

Log in to post comments