Splunk Search

How to use a wildcard with a where clause?

allladin101
Explorer

Hi - I wish to use a wildcard in the where clause in the below query can someone help?

index=whatever* sourcetype=server
|rex field=CLIENT_VERSION "\'(?P.+)\'" 
|table version
|where version=*10_2*

here the value in the version field is FS_10_2_17387/FS_10_2_12387/FS_10_2_17987

Tags (4)
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi alladin101,

it's me again 🙂

Now I get it; no this is not the way you use where. If you use where you will compare two fields and their respective values. You would have to use search because this will search using the value of the field.

like this:

index=whatever* sourcetype=server
 |rex field=CLIENT_VERSION "\'(?P.+)\'" 
 |table version
 |search version=*10_2*

hope this helps...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi alladin101,

it's me again 🙂

Now I get it; no this is not the way you use where. If you use where you will compare two fields and their respective values. You would have to use search because this will search using the value of the field.

like this:

index=whatever* sourcetype=server
 |rex field=CLIENT_VERSION "\'(?P.+)\'" 
 |table version
 |search version=*10_2*

hope this helps...

cheers, MuS

MoniM
Communicator

hi,
if i want to add multiple values in the version field, can i use "AND" operator in search command?
for eg: | search version= 10 AND 12 AND 13
or how to include all three values in version field?

0 Karma

MuS
SplunkTrust
SplunkTrust

How about this?
.... | search version="10" version="12" version="13"

0 Karma

markbarber21
Path Finder

FYI - the optimizer will combine this into search(index=whatever* sourcetype=server version=*10_2*), as if it was part of the original search query.

0 Karma

MuS
SplunkTrust
SplunkTrust

Yes, this is the difference between using where and search ; search can be basically used in the base/original search where as where will compare/eval values of fields ... even back in 2014 😉

cheers, MuS

0 Karma

LAcioffi
Explorer

This just saved my life! Thanks!

0 Karma

allladin101
Explorer

Hi Mus,

Thanks for the answer 🙂

can i use this as well?
|where like(version,"%FX_10_2%")

MuS
SplunkTrust
SplunkTrust

yes, this should work as well

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...