<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to set a token with eval? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223131#M65670</link>
    <description>&lt;P&gt;Have you tried        &lt;/P&gt;

&lt;P&gt;rtrim(src,"_txn_log") &lt;/P&gt;

&lt;P&gt;Without the ' char?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 11:04:51 GMT</pubDate>
    <dc:creator>jamesmarlowww</dc:creator>
    <dc:date>2020-09-29T11:04:51Z</dc:date>
    <item>
      <title>How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223122#M65661</link>
      <description>&lt;P&gt;I'm trying to set a token with eval. However, my logic doesn't seem to be working. I haven't been able to find a working example in the docs or from Answers, so a nudge in the right direction would be appreciated &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;input type="text" token="stuff"&amp;gt;
 &amp;lt;label&amp;gt;test&amp;lt;/label&amp;gt;
 &amp;lt;default&amp;gt;bband&amp;lt;/default&amp;gt;
 &amp;lt;change&amp;gt;
    &amp;lt;eval token="stuff"&amp;gt;replace($stuff$, ",", " OR ACCOUNT_NO=")&amp;lt;/eval&amp;gt;
 &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Have also tried using &lt;CODE&gt;'&lt;/CODE&gt; chars instead of &lt;CODE&gt;$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 21:39:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223122#M65661</guid>
      <dc:creator>jamesmarlowww</dc:creator>
      <dc:date>2016-04-26T21:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223123#M65662</link>
      <description>&lt;P&gt;Did you try no chars?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 21:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223123#M65662</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2016-04-26T21:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223124#M65663</link>
      <description>&lt;P&gt;Thanks. Have now... seems to be half working. But my replace function is only picking up the first occurance. Unlike using it in splunk search &lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 21:51:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223124#M65663</guid>
      <dc:creator>jamesmarlowww</dc:creator>
      <dc:date>2016-04-26T21:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223125#M65664</link>
      <description>&lt;P&gt;Hi @jamesmarloww,&lt;BR /&gt;
I'm not sure of all of the details of the result you are trying to create with "eval" and a token. In case it helps, "eval" expressions in dashboards do use the same syntax as SPL "eval", but there are some exceptions to their behavior and usage (including the regular expression library). See:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.0/Viz/tokens#Custom_logic_for_dashboards"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.0/Viz/tokens#Custom_logic_for_dashboards&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;for notes on how dashboard "eval" differs from SPL eval:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/Eval"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also, have you seen the eval example in the Dashboard Examples App?&lt;BR /&gt;
&lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 23:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223125#M65664</guid>
      <dc:creator>frobinson_splun</dc:creator>
      <dc:date>2016-04-26T23:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223126#M65665</link>
      <description>&lt;P&gt;Yeah I think differences between the SPL eval and XML eval is what is causing different results. &lt;/P&gt;

&lt;P&gt;"It is also important to note that regular expressions in dashboard eval expressions use the syntax and semantics of the JavaScript regular expression engine. This is not the same engine used for SPL eval expressions. If you are using regular expressions in search tokens, check that syntax and semantics match those for JavaScript."&lt;/P&gt;

&lt;P&gt;Anyways thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184042"&gt;@frobinson_splun&lt;/a&gt;k and &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/76487"&gt;@aljohnson_splun&lt;/a&gt;k for your time and advice &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:33:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223126#M65665</guid>
      <dc:creator>jamesmarlowww</dc:creator>
      <dc:date>2020-09-29T09:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223127#M65666</link>
      <description>&lt;P&gt;Have you tried $value$ instead of $stuff$?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2016 17:58:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223127#M65666</guid>
      <dc:creator>13yqiao</dc:creator>
      <dc:date>2016-07-15T17:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223128#M65667</link>
      <description>&lt;P&gt;From my comments above, it looks like I got it mostly working like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;eval token="stuff"&amp;gt;replace(stuff, ",", " OR ACCOUNT_NO=")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2016 02:29:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223128#M65667</guid>
      <dc:creator>jamesmarlowww</dc:creator>
      <dc:date>2016-07-20T02:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223129#M65668</link>
      <description>&lt;P&gt;I have used eval previously to straighten out a user input and then normalize the data. My case was, user enters a MAC address (Since it users, could be in any of the know MAC address formats), so we assigned the entry to a token, then applied eval to format it to our comfort. This was done in the search though. Just posting it in hope that it will give you some more ideas&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[search index=blah | eval MacAddress=$MAC|s$|eval MAC=replace(MacAddress,"([-:\.])","")|return MAC]&lt;/CODE&gt;| wrapped in a subsearch which finally feeds the normalized MAC back to parent search.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Raghav&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2016 03:14:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223129#M65668</guid>
      <dc:creator>Raghav2384</dc:creator>
      <dc:date>2016-07-20T03:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223130#M65669</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;Even i am facing the related issue.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        &amp;lt;condition field="_raw"&amp;gt;
        &amp;lt;set token="serv"&amp;gt;$serv$&amp;lt;/set&amp;gt;
        &amp;lt;set token="src"&amp;gt;$row.source$&amp;lt;/set&amp;gt;

       &amp;lt;eval token="srcEval"&amp;gt;rtrim('src',"_txn_log")&amp;lt;/eval&amp;gt; 

        &amp;lt;set token="uri"&amp;gt;$row.uri$&amp;lt;/set&amp;gt;
        &amp;lt;set token="_raw"&amp;gt;$click.value2$&amp;lt;/set&amp;gt;
       &amp;lt;/condition&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to set token(srcEval) by using eval command..but it is not working ...Could you help ??&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 10:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223130#M65669</guid>
      <dc:creator>SwamyRaj</dc:creator>
      <dc:date>2016-09-22T10:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223131#M65670</link>
      <description>&lt;P&gt;Have you tried        &lt;/P&gt;

&lt;P&gt;rtrim(src,"_txn_log") &lt;/P&gt;

&lt;P&gt;Without the ' char?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223131#M65670</guid>
      <dc:creator>jamesmarlowww</dc:creator>
      <dc:date>2020-09-29T11:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223132#M65671</link>
      <description>&lt;P&gt;Did you get this to work? My eval token is only replacing the first occurence too. On 6.5.1 with the following where I try to change:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;index=bla OR index=foo&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;To&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;bla,foo&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;by using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="multiselect" token="tenant_indexes" depends="$multi_tenancy$"&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="tenant_indexes_filter"&amp;gt;replace(replace(tenant_indexes,"index=","")," OR ",",")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
      &amp;lt;label&amp;gt;Tenant&amp;lt;/label&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;tenant_name&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;index&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;| `get_tenants_for_user_role($env:user$)`&amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;default&amp;gt;index=*&amp;lt;/default&amp;gt;
      &amp;lt;delimiter&amp;gt; OR &amp;lt;/delimiter&amp;gt;
      &amp;lt;choice value="index=*"&amp;gt;All&amp;lt;/choice&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2016 14:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223132#M65671</guid>
      <dc:creator>mikaelbje</dc:creator>
      <dc:date>2016-11-29T14:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223133#M65672</link>
      <description>&lt;P&gt;Below should work -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;eval token="stuff"&amp;gt;replace('value', ",", " OR ACCOUNT_NO=")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Apr 2018 13:34:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223133#M65672</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2018-04-01T13:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a token with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223134#M65673</link>
      <description>&lt;P&gt;Check out &lt;CODE&gt;eval token&lt;/CODE&gt; here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 05:56:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-token-with-eval/m-p/223134#M65673</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-19T05:56:58Z</dc:date>
    </item>
  </channel>
</rss>

