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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...