Splunk Search

Show only fields values found in subsearch

niuk
Engager

I have search like below to show me 'src_ip' and 'count' every last 10 min

index="pan" sourcetype="pan:threat" earliest=-10m action=allowed NOT [| inputlookup Exclusions | fields src_ip] | stats count by src_ip| where count > 10 | sort - count

1.1.1.1 10

2.2.2.2 12

and second search to show only src_ip in last 24h (to eliminate src_ip repeated in any of 10 min periods for last 24h)

index="pan" sourcetype="pan:threat" earliest =-24h action=allowed NOT [| inputlookup Exclusions ] | bin _time span=10m | stats count by _time src_ip | where count > 10 | stats count by src_ip | where count = 1 | fields - count

but combined search to show my only src_ip with count where src_ip is present in subsearch is not working correctly .. because src_ip values are not unique in subsequent 10 min interval

index="pan" sourcetype="pan:threat" earliest=-10m action=allowed NOT [| inputlookup Exclusions | fields src_ip] | stats count by src_ip| where count > 10 | sort - count IN [index="pan" sourcetype="pan:threat" earliest =-24h action=allowed NOT [| inputlookup Exclusions ] | bin _time span=10m | stats count by _time src_ip | where count > 10 | stats count by src_ip | where count = 1 | fields - count]

 

 

 

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

I suspect one reason the combined query is not working correctly is the questionable syntax.  Specifically, the sort - count IN [<subsearch].  Splunk will attempt to sort the results by the count and IN fields as well as the text returned by the subsearch (interpreted as column names).  It may sort results, but they won't be the expected results.

When working with subsearches, always run the subsearch by itself with | format appended to it.  The resulting string is what will be added to the main search and executed.  Make sure the result make sense as part of the main search.

---
If this reply helps you, Karma would be appreciated.

niuk
Engager

Appreciate looking at it , I run subsearch with '| format' and got below (...cut output)

 

( ( src_ip="10.1.136.6" ) OR ( src_ip="10.1.2.4" ) OR .....cut output )

 

Does the format of subsearch looks good ? Dont know how to pipe that subsearch other than inserting IN after main search...

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...