Splunk Search

Is there any workaround in Splunk to make a star to be considered as constant instead of wild card?

pavanae
Builder

I have some fields as follows

sql="Select * from & ABC"
sql="Select * from xyz.ABC"
sql="Select * from gh2_ABC"
sql="Select * from 34,rABC"
sql="Select * from xyz.gfr"

Now I am trying to work on an event type as follows

eventtype name :- test

sourcetype="web" sql="Select * from *ABC"

And now I want to consider the first star as a constant and the second star as a wild card. Is there any workaround in Splunk to make a star to be considered as constant instead of wild card?

0 Karma
1 Solution

DalJeanis
Legend

In search, an asterisk is a wildcard. There is no workaround.

In a regex, an asterisk can be either a repeater, or it can be escaped \* to be a plain asterisk.

When using | like(), asterisk is a regular character and % is a wildcard.

View solution in original post

0 Karma

cpetterborg
SplunkTrust
SplunkTrust

As far as I know there is no base search (with the search command) that will make a * be a constant. But you can use the regex command to do an asterisk as a constant. For example, the following works to find the asterisk as an asterisk:

| makeresults 
| eval raw="sql=\"Select from & ABC\"
sql=\"Select from xyz.ABC\"
sql=\"Select * from xyz.gfr\""
|  makemv raw delim="
"  | mvexpand raw 
|  rename raw as _raw 
|  regex "Select \*"

If you change the regex to search, you will get all three events, instead of just one. Hopefully this is something that you can use in your application.

0 Karma

DalJeanis
Legend

In search, an asterisk is a wildcard. There is no workaround.

In a regex, an asterisk can be either a repeater, or it can be escaped \* to be a plain asterisk.

When using | like(), asterisk is a regular character and % is a wildcard.

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