Is it possible to search for a literal * character? If I had a string in a log that read "hi*there", and I wanted to search for it specifically
Using the search language to search for a literal *
is currently unsupported. One workaround is to disable "*" as wildcard and then you can search for it as a literal, but but then you no longer have any wildcard capabilities; which was unacceptable to me to so I did peruse that option with Splunk support.
This is listed on the "Known Issues" page as follows:
There is no way to escape an asterisk (*) in the search language. (SPL-30079)
Just to be clear, you can filter for a "*
" using a post-processing search command (e.g. by using rex
like in the answer above), but you can't actually search for one in your actual search.
Using the search language to search for a literal *
is currently unsupported. One workaround is to disable "*" as wildcard and then you can search for it as a literal, but but then you no longer have any wildcard capabilities; which was unacceptable to me to so I did peruse that option with Splunk support.
This is listed on the "Known Issues" page as follows:
There is no way to escape an asterisk (*) in the search language. (SPL-30079)
Just to be clear, you can filter for a "*
" using a post-processing search command (e.g. by using rex
like in the answer above), but you can't actually search for one in your actual search.
The first thing that comes to mind is a regular expression. I tried the following and it seems to work:
| rex field=_raw "(?<myLiterals>\w*\*\w*)"
The values of any data with "*" inside them at any point will be stored in the field "myLiterals". Did you only want the values, or did you also want the location of these values?
You can use
"complex search" | where searchmatch("complex search") OR match("\*",_raw)
what if I want to search for
"complex search" OR "hi*there"?
I don't want to have to embed complex search into a regex just to filter for literal asterixes.
you will want to do "hi" "there" | regex _raw="hi\*there"
, since that will first use the index to return only events containing "hi" and "there", then further filter down to items containing the exact string you're looking for.
Ah, I see.
In that case, we could use "regex" instead, which will only keep events that match the regular expression.
| regex _raw="\w*\*\w*"
Is this closer to what you're after?
Ideally I'd like to just have splunk return events like it normally does with the highlighting of what it matched on inline vs extracting the data with rex.
The string I'm searching for is part of a much larger query, so piping to rex would only extract that particular string.