Hi Folks,
I need your help in fetching latest event from a particular field.
Sharing you a sample event and query when I execute for last 15 mins.
Query -> index=Blah sourcetype=blah_blah*
Example event :-
I think you can use where condition to filter out events which belong to last 15 minutes for the field SNAPTIME_NEW
| eval limit = relative_time(now(),"-15m")
| where SNAPTIME_NEW >= limit
| sort SNAPTIME_NEW
If the field is not already in epoch time, you will have to convert it using strptime.
@t_shreya Thanks for your response, but this does not seem to be returning any result.
Screenshot attached for your reference.
And yes field is already in epoch time.
@prateeksawhney , if the SNAPTIME_NEW does not have field values that are equal to or greater than the epoch time of the last 15 min, then, it would not return any result.
Does the SNAPTIME_NEW have all the values that are older than last 15 min?
Your Question -
Does the SNAPTIME_NEW have all the values that are older than last 15 min?
Answer - Yes
I have updated my question, I need to look for only today's events in a sorted manner. As of now I am getting around 22,000 events in last 15 mins which contain old and new both dates.
Screenshot attached.
Hi @prateeksawhney ,
For today's events you would need to change -15m to @d
| eval limit = relative_time(now(),"@d")
| where SNAPTIME_NEW >= limit
| sort SNAPTIME_NEW
This query is not returning any results.
@prateeksawhney , Can you share details about the field SNAPTIME_NEW, means some of the values that it has in it?
| eval limit = relative_time(now(),"-15m")
| eval SNAPTIME_NEW=strptime(SNAPTIME_NEW,"%m/%d/%y %H:%M:%S")
| where SNAPTIME_NEW >= limit
| sort SNAPTIME_NEW
Hi, Thanks for your response. But your query is not returning any results either.
All the events you have shown have old dates in SNAPTIME. Are there any results to be found matching your criteria?