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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...