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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Building Momentum: Splunk Developer Program at .conf25

At Splunk, developers are at the heart of innovation. That’s why this year at .conf25, we officially launched ...