Dashboards & Visualizations

How to use value from a drop down that contains reserved characters in a search?

robert_adams
Engager

I have a table that shows instances of errors from the event log over time by host.

I use a drop down that searches the event log data for Type="Error" | top limit=20 Message to populate $ErrorMessage$ with the value in the Message column. Then I have a table that uses $ErrorMessage$ and does this search:

Type="Error" Message ="$ErrorMessage$" | eval host=upper(host) | timechart count by host

The table and the drop down both default to 24 hour periods.

It works, except when the Message contains reserved characters, like [ or ]. Then I don't get any matches, even though results show in the drop down.

Do I need to escape characters in $ErrorMessage$ when I do my search for the timechart? If so, how do I do that without knowing what characters will show up or how many?

0 Karma

to4kawa
Ultra Champion

Drop Down search:

your_search
| stats count values(host) as host by Message 
| sort 20 - count
| nomv host
| rex field=host mode=sed "s/(\S+)/host=\"\1\" OR /g"
| eval searchquery=trim(host,"OR ")

throw searchquery field.

Timechart search:

Type="Error"  $searchquery$" | eval host=upper(host) | timechart count by host
0 Karma

to4kawa
Ultra Champion
| makeresults
| eval test="[]{}!\"#$%&'()?>< abddeft ?>_test"
| eval test3=replace(test,"[^\w]","_")
| eval test2=$test$

The token looks OK,
If necessary, convert it?

0 Karma

robert_adams
Engager

Unfortunately it still came back with no data when I quoted the token and errors when I didn't. I finally got it to work by using the hash for the error message. Thanks.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...