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!

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...

Splunkbase | Splunk Dashboard Examples App for SimpleXML End of Life

The Splunk Dashboard Examples App for SimpleXML will reach end of support on Dec 19, 2024, after which no new ...

Understanding Generative AI Techniques and Their Application in Cybersecurity

Watch On-Demand Artificial intelligence is the talk of the town nowadays, with industries of all kinds ...