Splunk Search

Separate multiple splunk values with an OR clause?

MM0071
Path Finder

I have a text box in a splunk dashboard and I'm trying to find out how I can separate values entered into the text box that are separated by commas with a OR clause. for example:

values entered into text box: 102.99.99, 103.99.93, 203.23.21

Where this search (index=abc sourcetype=abc src_ip="$ip$") would translate to:

 index=abc sourcetype=abc src_ip="102.99.99 OR 103.99.93 OR 203.23.21"

Any suggestions?

 
0 Karma
1 Solution

johnhuang
Motivator

Your best bet for this scenarios is to use "IN" which allows you to search for a comma delimited list of values.

For this to work, the input needs to be comma delimited, does not support "OR".

E.g. your input: 102.99.99, 103.99.93, 203.23.21

 

Change this: 
index=abc sourcetype=abc src_ip="$ip$"

To this: 
index=abc sourcetype=abc src_ip IN ($ip$)

 

 

View solution in original post

johnhuang
Motivator

Your best bet for this scenarios is to use "IN" which allows you to search for a comma delimited list of values.

For this to work, the input needs to be comma delimited, does not support "OR".

E.g. your input: 102.99.99, 103.99.93, 203.23.21

 

Change this: 
index=abc sourcetype=abc src_ip="$ip$"

To this: 
index=abc sourcetype=abc src_ip IN ($ip$)

 

 

MM0071
Path Finder

This was perfect. Thank you. Not sure why I didn't think about this.

gcusello
SplunkTrust
SplunkTrust

Hi @MM0071,

did you tried with replace command (https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Replace)?

| replace "," WITH " OR" IN <your_field>

  Ciao.

Giuseppe

0 Karma

MM0071
Path Finder

I have not. I'm very green with Splunk. How would the syntax for this work?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...