Splunk Enterprise

eval Token Regex, Need to remove open & close brackets

AnilPujar
Path Finder

I need help removing these open & closed brackets in the token, please see below the dashboard code FYI

 

 

<form>
  <label>token eval drilldown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="manager" searchWhenChanged="true">
      <label>Account Managers</label>
      <choice value="*">All</choice>
      <choice value="123&quot;,&quot;456&quot;,&quot;789&quot;,&quot;431C&quot;,&quot;343">XYZ</choice>
      <choice value="786&quot;,&quot;274&quot;,&quot;245&quot;,&quot;237&quot;,&quot;2523&quot;,&quot;245&quot;,&quot;257">ABC</choice>
      <choice value="463&quot;,&quot;234&quot;,&quot;234&quot;,&quot;3543">DEF</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>| search u_user_type IN (</prefix>
      <suffix>)</suffix>
      <!--<valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>-->
      <change>
        <condition>
          <eval token="tok_manager">replace($manager$,"(.\| search u_user_type IN \()","")</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$manager$</p>
        <p>$tok_manager$   &lt;-- i need to remove these open &amp; close brackets</p>
      </html>
    </panel>
  </row>
</form>

 

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You need an extra backslash on the escapes

<form version="1.0.0">
  <label>token eval drilldown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="manager" searchWhenChanged="true">
      <label>Account Managers</label>
      <choice value="*">All</choice>
      <choice value="123&quot;,&quot;456&quot;,&quot;789&quot;,&quot;431C&quot;,&quot;343">XYZ</choice>
      <choice value="786&quot;,&quot;274&quot;,&quot;245&quot;,&quot;237&quot;,&quot;2523&quot;,&quot;245&quot;,&quot;257">ABC</choice>
      <choice value="463&quot;,&quot;234&quot;,&quot;234&quot;,&quot;3543">DEF</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>| search u_user_type IN (</prefix>
      <suffix>)</suffix>
      <!--<valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>-->
      <change>
        <condition>
          <eval token="tok_manager">replace(replace($manager$,"(\\| search u_user_type IN \\()",""),"(\\))","")</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$manager$</p>
        <p>$tok_manager$   &lt;-- i need to remove these open &amp; close brackets</p>
      </html>
    </panel>
  </row>
</form>

View solution in original post

AnilPujar
Path Finder

Thanks, @ITWhisperer 

It worked

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You need an extra backslash on the escapes

<form version="1.0.0">
  <label>token eval drilldown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="manager" searchWhenChanged="true">
      <label>Account Managers</label>
      <choice value="*">All</choice>
      <choice value="123&quot;,&quot;456&quot;,&quot;789&quot;,&quot;431C&quot;,&quot;343">XYZ</choice>
      <choice value="786&quot;,&quot;274&quot;,&quot;245&quot;,&quot;237&quot;,&quot;2523&quot;,&quot;245&quot;,&quot;257">ABC</choice>
      <choice value="463&quot;,&quot;234&quot;,&quot;234&quot;,&quot;3543">DEF</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>| search u_user_type IN (</prefix>
      <suffix>)</suffix>
      <!--<valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>-->
      <change>
        <condition>
          <eval token="tok_manager">replace(replace($manager$,"(\\| search u_user_type IN \\()",""),"(\\))","")</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$manager$</p>
        <p>$tok_manager$   &lt;-- i need to remove these open &amp; close brackets</p>
      </html>
    </panel>
  </row>
</form>
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...