Dashboards & Visualizations

How do you change the token value before a search?

damucka
Builder

Hello,

In my dashboard, I am using the custom drilldown where I want to pass a filename to a search. For Windows, it seems I have to replace the single backslash with a double backslash in order for the search to work.

Now, I would like to change the value of my token before search. The original drilldown search with single backslash in the file path was:

    * source="$row.Tracefile$"

I wanted to replace it with something like this:

    * source= search[|eval Tracefile="$row.Tracefile$" | rex mode=sed field=Tracefile "s/(\\\)/\1\1/g"]

But it does not work.

Is there any simple way to replace the \ with \ in the $row.Tracefile$ before using it in the Drilldown search?

Kind Regards,
Kamil

Tags (2)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Have you tried source=$row.Tracefile|s$ to let Splunk escape some values and wrap the result in quotes? Not sure if it handles backslashes, but worth a try.

If that doesn't work you can use <eval token="escaped_tracefile">escape logic here</eval> in your drilldown instead of <set ...>.

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Have you tried source=$row.Tracefile|s$ to let Splunk escape some values and wrap the result in quotes? Not sure if it handles backslashes, but worth a try.

If that doesn't work you can use <eval token="escaped_tracefile">escape logic here</eval> in your drilldown instead of <set ...>.

0 Karma
Get Updates on the Splunk Community!

Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

 Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...

Cloud Platform | Migrating your Splunk Cloud deployment to Python 3.7

Python 2.7, the last release of Python 2, reached End of Life back on January 1, 2020. As part of our larger ...