Splunk Search

Subsearch does not work

simuvid
Splunk Employee
Splunk Employee

What is wrong with following search:

sourcetype="security" ip=[search sourcetype=access_combined status=401 clientip=* | transaction fields clientip | where eventcount>2 | stats count, values(clientip) by status]

What I get is following message:

Error in 'search' command: Unable to parse the search: Comparator '=' has an invalid term on the right hand side.

Any hints?

Cheers

simuvid

Tags (1)
1 Solution

ziegfried
Influencer

A subsearch is used this way:

sourcetype="security" [ search sourcetype=access_combined status=401 clientip=* | transaction fields clientip | where eventcount>2 | fields clientip | dedup clientip | rename clientip as ip ]

The subsearch should return a result like this

|    ip     |
| --------- |
| 10.1.1.1  |
| 10.1.1.2  |
| 10.1.1.3  |

Which will expanded to the following condition:

( ( ip="10.1.1.1") OR (ip="10.1.1.2") OR (ip="10.1.1.3") )

You can inspect the conditions generated by the subsearch by executing:

sourcetype=access_combined status=401 clientip=* | transaction fields clientip | where eventcount>2 | fields clientip | dedup clientip | rename clientip as ip | format

View solution in original post

ziegfried
Influencer

A subsearch is used this way:

sourcetype="security" [ search sourcetype=access_combined status=401 clientip=* | transaction fields clientip | where eventcount>2 | fields clientip | dedup clientip | rename clientip as ip ]

The subsearch should return a result like this

|    ip     |
| --------- |
| 10.1.1.1  |
| 10.1.1.2  |
| 10.1.1.3  |

Which will expanded to the following condition:

( ( ip="10.1.1.1") OR (ip="10.1.1.2") OR (ip="10.1.1.3") )

You can inspect the conditions generated by the subsearch by executing:

sourcetype=access_combined status=401 clientip=* | transaction fields clientip | where eventcount>2 | fields clientip | dedup clientip | rename clientip as ip | format

simuvid
Splunk Employee
Splunk Employee

Thanks!!!

That one works as expected!

Cheers,

simuvid

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...