![]() |
![]() |
Subject: | fully setting event fields and dealing with multi-line data |
Author: | Luke Lofgren |
Posted: | 2018-09-21 08:21 |
I use the following router call to create events using the API:
data = dict(device=device_name, summary=summary, severity=severity,
component=component, evclasskey=evclasskey, evclass=evclass)
return self.__router_request('EventsRouter', 'add_event', [data])
I have been frustrated in the past by not having field names to directly post to fields in events -- there's a comment in the developer guide that "For other parameters please see class Event." -- I don't know where to find that. Not sure that this is going to give me additional data field names.
Basically I want a methodical way to determine for a given event field, including potentially ones that are "sub-fields" that I can create an event using the API with all the values that I want to provide.
In the interim I "overloaded" the summary field with the data that I wanted to set and then used this transform to break it out to the fields I wanted (summary in the API isn't actually summary, its message, with the first set of characters set to summary):
import re
evt.summary=re.search('(?<=SUMMARY:)(.*)(MESSAGE:)',evt.message).group(1)
evt.fault_type=re.search('(?<=FAULT_TYPE:)(.*)(ENDMESSAGE)',evt.message).group(1)
evt.message=re.search('(?<=MESSAGE:)(.*)(?<=FAULT_TYPE:)',evt.message,re.DOTALL).group(0)[:-11]
Not being a sophisticated regex user, it took me an hour to figure out the syntax on that last one to allow multi-line input messages to be found (I still probably could improve on it).
Thanks in advance for any guidance!
Subject: | RE: fully setting event fields and dealing with multi-line data |
Author: | Steve Aiello |
Posted: | 2018-10-31 12:18 |
{ "action": "EventsRouter", "method": "add_event", "data": [{ "summary": "this is a test", "device": "testAdd1", "component": "test", "severity": 4, "evclasskey": "sma", "evclass": "/Perf/CPU", "coolNewField": "cowBell", "Ren": "Stimpy" } ], "tid": 1 }
< |
Previous How to execute command on Noviflow Switch |
Next COMMAND data source testing failing |
> |