Splunk Search

How to compare the values with the time and host?

Anud
Explorer

Team,

I am having a query which would result as below.

_time Host Name version
3/2/2022  15:22:04 PM 3 car 248
3/1/2022  15:21:04 PM 3 car 246
3/1/2022  15:20:07PM 2 car 246
3/1/2022  15:20:03 PM 3 bus 600
3/1/2022  15:19:02 PM 2 bus 600
2/1/2022  15:20:03 PM 3 Toy 600
2/1/2022  15:19:02 PM 2 Toy 248
2/1/2022  14:19:02 PM 2 Toy 248

 

After that i need final output like below.

_time Host Name version Final
2/1/2022  15:20:03 PM 3 Toy 600 Not matching
3/1/2022  15:20:03 PM 3 bus 600 Matched
3/1/2022  15:21:04 PM 3 car 246 Matched
3/2/2022  15:22:04 PM 3 car 248 Not matching

 

 I am not sure to compare between columns itself. Could someone please help me out here.

Thanks

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eventstats dc(Host) as hosts by Name version
| stats latest(_time) as _time latest(Host) as Host by Name version hosts
| eval Final=if(hosts = 2, "Matched","Not matching")

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What are your criteria for matching the columns?

0 Karma

Anud
Explorer

Host is the criteria.

We need to check host latest and earliest time in a day... accordingly thier names and version have to compare.

Thankyou

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Why is bus/600 matched when there is a host with a different number on the same day?

Why is car/248 not matched when there isn't another entry for the same day?

0 Karma

Anud
Explorer

Here target is to check the version for the host and their names.

So we have only 2hosts...final version is compared to 2and 3hosts with their same names.

Sometimes it takes to another day,so we need compare pervious day host latest time.

Thank you

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eventstats dc(Host) as hosts by Name version
| stats latest(_time) as _time latest(Host) as Host by Name version hosts
| eval Final=if(hosts = 2, "Matched","Not matching")
0 Karma

Anud
Explorer

Thank you !!

Tags (1)
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk Cloud Platform 9.1.2308?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2308! Analysts can ...

Index This | Why do they call it hyper text?

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

State of Splunk Careers 2023: Career Resilience and the Continued Value of Splunk

For the past three years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...