Splunk Search

How to compare value of 2 logfiles for notification?

simon9
Explorer

Hi all,

I'm a beginner working with splunk. I have 2 Logfiles with the same Name, but from 2 different Hosts. I would like to compare both file for an expression (e.g. "server disconected") and only get the result, when the same expression is in both file in the sime time-period (last 10 min.)  so that i could use the select for a notification.

I hope you understand what i mean🙂

Thanks, Simon

Labels (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @simon9,

sorry, I understood exactly the opposite!

with my search you count the number of different hosts, when the count is two, means that's present in both hosts.

please, try this:

index=your_index source="yoursource" "server disconnected"
| stats dc(host) AS dc_host values(host) AS host
| where dc_host=2

Ciao.

Giuseppe

View solution in original post

simon9
Explorer

Ciao @gcusello 

thanks for your fast response! I tried it, but i get the data also if the entrie is just in one logfile .  I need a result only, if the expression "server disconnect" is in both logfile at the same time.

e.g:

Logfile from "host 1" has 10 entrys "server disconnected" and logfile from "host 2" has 2 entrys "server disconnected" in the same timeperiod -> result should be 12.

Logfile from "host 1" has 10 entrys "server disconnected" and Logfile from "host 2" has 0 entrys "server disconnected" in the same timeperiod  -> result would be 0.

Thanks, Simon

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @simon9,

sorry, I understood exactly the opposite!

with my search you count the number of different hosts, when the count is two, means that's present in both hosts.

please, try this:

index=your_index source="yoursource" "server disconnected"
| stats dc(host) AS dc_host values(host) AS host
| where dc_host=2

Ciao.

Giuseppe

simon9
Explorer

@gcusello you don't need to apologize, my description was not the best !

I tried the new statement, but unfortunately i still get the result, althoug just 1 logfile (Host) has entrys.

simon9_0-1645632278780.png

 

Thank you for your Help!

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @simon9,

you don't have results: the statistics tab is empty, you have two events from the same host, 

Ciao.

Giuseppe

0 Karma

simon9
Explorer

@gcusello OK, i understand. Grazie Mille for your help

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @simon9,

good for you, see next time!

Ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated 😉

gcusello
SplunkTrust
SplunkTrust

Hi @simon9,

try something like this:

index=your_index source="yoursource" "server disconnected"
| stats dc(host) AS dc_host values(host) AS host
| where dc_host=1
| table host

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Video | Welcome Back to Smartness, Pedro

Remember Splunk Community member, Pedro Borges? If you tuned into Episode 2 of our Smartness interview series, ...

Detector Best Practices: Static Thresholds

Introduction In observability monitoring, static thresholds are used to monitor fixed, known values within ...

Expert Tips from Splunk Education, Observability in Action, Plus More New Articles on ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...