Splunk Search

Loop through event message

gurkiratsingh
Explorer

Hi I want to compare a date time value with many entities in my message. I have an eval(IST_time_latest) with the value 2020-04-13 00:00:00 and I want to check whether this eval is equal to all the datetimes in (message.abc.cat, message.abc.dog, message.abc.man, message.abc. hello)

The event message is like this:-
{
message: { [-]
abc: { [-]
cat: 2020-04-13 00:00:00
dog: 2020-04-13 00:00:00
man: 2020-04-13 00:00:00
hello: 2020-04-13 00:00:00
} } }

| eval flag_cat=if( (IST_time_latest=='message.abc.cat') ,"TRUE","FALSE")
| eval flag_dog=if( (IST_time_latest=='message.abc.dog') ,"TRUE","FALSE")
|table flag_cat, flag_dog

So there are 50+ entities like this in the messages and I do not want to create a flag like this for all of them. Can you please suggest an alternative??

0 Karma

to4kawa
Ultra Champion
....
| spath path=message{}.abc{} output=message
| stats values(IST_time_latest) as IST_time_latest by message
| spant input=message
| fields - message  _*
| eval flag_cat=if(IST_time_latest==cat ,"TRUE","FALSE")

How's this?

0 Karma

gurkiratsingh
Explorer

Hi this is extracting all the 50+ dates correctly but can you also tell me where to put the compare sort of thing to get true or false for all. I have to compare with (IST_time_latest)
example: | eval flag_cat=if( (IST_time_latest=='message.abc.cat') ,"TRUE","FALSE")

0 Karma

to4kawa
Ultra Champion

I see, my answer is updated

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...