Data Infrastructure Management Software Discussions

OnTAP event query from SDK - want only events after a specified time

I am attempting to write an EMS event query using the NMSDK against cDOT clusters that will only return events from a given timestamp forward. This would be similar to the OnTAP command:

event log show -event *fpolicy*  -time >="9/28/2018 10:29:55"

 

The query parameter seems to allow for queries AT a specified time, but not for AT OR AFTER (">="). Am I missing something? Is there some way to specify the "time" field to accomplish this? It appears that it will only accept an integer value - number of seconds since the epoch - but there doesn't appear to be any provision for a relational operator.

 

If it matters I am using Perl.

 

Please advise. This would be a great boon to our troubleshooting and monitoring efforts.

 

Thank you for your attention to this matter,

    Scott Lindley

3 REPLIES 3

Re: OnTAP event query from SDK - want only events after a specified time

If my python code help you. 

 

api = NaElement("event-iter")
xi = NaElement("time-range")
api.child_add(xi)
xi1 = NaElement("event-timestamp-range")
xi.child_add(xi1)
xi1.child_add_string("end-time", int(unix_timestamp))
xi1.child_add_string("start-time", int(unix_timestamp_minus_30_min))
xo = serv.invoke_elem(api)
xo1 = xo.child_get("records")

 

Where time is could be any range though in my case I am using like this

 

current_time = datetime.datetime.now(datetime.timezone.utc)
unix_timestamp = current_time.timestamp()
unix_timestamp_minus_30_min = unix_timestamp - (5 * 60)


now to past 30 min

 

Re: OnTAP event query from SDK - want only events after a specified time

Thanks for the reply, it's really appreciated. Unfortunately this is a query against Unified Manager, which only captures certain events from clusters. I'm looking for a query straight to the cluster so I can enumerate any event that occurs during the time frame. It appears that, while the CLI supports this to some extent, the API does not. Unfortunate.

Re: OnTAP event query from SDK - want only events after a specified time

How about PowerShell? Looks like you could get the information you need with the "Get-NcEmsMessage" cmdlet. Something like this:

 

Connect-NcController <controller> 
Get-NcEmsMessage -MessageName *fpolicy* -StartTime "9/28/2018 10:29:55"

EDIT: The corresponding ZAPI call for that cmdlet is "ems-message-get-iter" if you'd prefer to query the API directly.  

Forums