Splunk Search

How to retrieve the same result in 2 similar search with count different?

jip31
Motivator

hi

In my dashboard, I use 2 similar searches

in the first, I am doing a dc of  "s"

 

 

index=test earliest=@d+7h latest=@d+19h
| search rtt >= 150
| stats count as Pb by s
| search Pb >= 5 
| stats dc(s)

 

 

the result is 12 

in the second search, i use the same search but I need to gather events also by "s" and also _time

 

 

index=test type=* earliest=@d+7h latest=@d+19h 
| bin span=1h _time  
| search rtt >= 150
| stats count as Pb by s _time 
| search Pb >= 5
| timechart dc(s) as sam span=1h 
| where _time < now() 
| eval time = strftime(_time, "%H:%M") 
| stats sum(s) as nbs by time 
| rename time as Heure

 

 

the pb I have is that the results is not equal to 12 but to 6

Why I can retrieve the same resulst that in the first search please?

Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Yes, this is sounds like a perfectly understandable result based on what the searches do. Whether this is what you intended might be a different matter, but only you can be the judge of that 😁

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The results are different because the first set of results is based on counts for the whole time period, whereas the second set of results is based on counts each hour.

0 Karma

jip31
Motivator

ok, but....

why I can see 7 different values for the field "s" in the first search while in the second search i just see 4 different values for field "s"?

Normally, all the field "s" which exists in the first search must exist in the second search but dispatched following the hour no?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Because you are searching for Pb > 5

This removes some instances of s if their counts for that hour do not satisfy this criteria. It is what your search is asking for.

0 Karma

jip31
Motivator

Ok i thing you are right even if it's not esay to visualize, 

so last thing could you confirm me that its normal that the result of distinct count done in the first search is different than when I aggregate the results of each bin _time of the second search?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Yes, this is sounds like a perfectly understandable result based on what the searches do. Whether this is what you intended might be a different matter, but only you can be the judge of that 😁

0 Karma
Get Updates on the Splunk Community!

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureThursday, March 27, 2025  |  11AM PST / 2PM EST | Register NowStep boldly ...

Splunk AppDynamics with Cisco Secure Application

Web applications unfortunately present a target rich environment for security vulnerabilities and attacks. ...