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
Legend

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
Legend

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
Legend

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
Legend

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
Legend

yes, this should work as well

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 ...