Splunk Search

Token eval Question

timm7474
Explorer

I'm trying to check the value of a token and if it is equal to "X" change it to an * but if it is equal to anything else, leave the token alone.  I'm trying something like this but not sure it is possible.

<drilldown>

<eval token='my_token'> if("X", "*", $my_token$)</eval>

<link target="_blank">search?q= my search...my_field=$my_token$.....blah blah blah...  </link>

</drilldown>

Thanks.

Labels (1)
0 Karma
1 Solution

timm7474
Explorer

This worked in the XML.  Thank you!

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try:

<drilldown>
<eval token="my_token"> if($my_token$="X", "*", $my_token$)</eval>
<link target="_blank">search?q= my search...my_field=$my_token$.....blah blah blah...  </link>
</drilldown>
0 Karma

timm7474
Explorer

Thanks for the quick reply, still no luck.  To add a bit more context, I am using click.name2 to grab column names to use in my search.  But when click.name2 is equal to the far right column name, I want to change the token to * since that name is a label for that column and not an actual searchable column name like the rest of the columns (if that makes sense).  I'm also using an eval in the search to get the column names and I tried adding this eval to the bottom under the search before the </drilldown> with still no luck.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So are you doing something like this?

<drilldown>
  <eval token="my_token">if($click.name2$="last","*",$click.name2$)</eval>
  <link target="_blank">search?q= my search...my_field=$my_token|u$.....blah blah blah...  </link>
</drilldown>

timm7474
Explorer

This worked in the XML.  Thank you!

0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...