<?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 Substituting token names again in Security</title>
    <link>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344640#M12649</link>
    <description>&lt;P&gt;Simple question I hope.&lt;/P&gt;

&lt;P&gt;I have a dashboard that uses many tokens from input drop downs, which allow the user to cause all dashboard elements to only consider events that match all the drop downs.  In my dashboard elements I end up having to put long conditions, such as (made up example):&lt;/P&gt;

&lt;P&gt;where ("$color$"="all" or "$color$"=color) and ("$type$"="all" or type="$type$") and ("$size$"="all" or size="$size$") and ....&lt;/P&gt;

&lt;P&gt;In an effort to reduce how many times I need to copy/update this large list of conditions across all the dashboard elements, I was hoping I could define a token like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;init&amp;gt;
  &amp;lt;set token="cond"&amp;gt;
    ("$color$"="all" or "$color$"=color) and ("$type$"="all" or type="$type$") and ("$size$"="all" or size="$size$") and ....
  &amp;lt;/set&amp;gt;
&amp;lt;/init&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That appeared to work by just putting a "where $cond$" in each element instead of the long condition, but now my dashboard elements didn't react to changes in the drop downs.  So I tried using $$ instead for the "cond" definition, but this causes all elements to return no results.  I figure this is probably because the inner tokens are not being substituted for their proper values.  Is there a way to cause this second level of substitution to happen?  Or, is there another way I can accomplish the same goal of defining my large condition in a single place?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 21:23:09 GMT</pubDate>
    <dc:creator>johnjester</dc:creator>
    <dc:date>2018-03-09T21:23:09Z</dc:date>
    <item>
      <title>Substituting token names again</title>
      <link>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344640#M12649</link>
      <description>&lt;P&gt;Simple question I hope.&lt;/P&gt;

&lt;P&gt;I have a dashboard that uses many tokens from input drop downs, which allow the user to cause all dashboard elements to only consider events that match all the drop downs.  In my dashboard elements I end up having to put long conditions, such as (made up example):&lt;/P&gt;

&lt;P&gt;where ("$color$"="all" or "$color$"=color) and ("$type$"="all" or type="$type$") and ("$size$"="all" or size="$size$") and ....&lt;/P&gt;

&lt;P&gt;In an effort to reduce how many times I need to copy/update this large list of conditions across all the dashboard elements, I was hoping I could define a token like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;init&amp;gt;
  &amp;lt;set token="cond"&amp;gt;
    ("$color$"="all" or "$color$"=color) and ("$type$"="all" or type="$type$") and ("$size$"="all" or size="$size$") and ....
  &amp;lt;/set&amp;gt;
&amp;lt;/init&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That appeared to work by just putting a "where $cond$" in each element instead of the long condition, but now my dashboard elements didn't react to changes in the drop downs.  So I tried using $$ instead for the "cond" definition, but this causes all elements to return no results.  I figure this is probably because the inner tokens are not being substituted for their proper values.  Is there a way to cause this second level of substitution to happen?  Or, is there another way I can accomplish the same goal of defining my large condition in a single place?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 21:23:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344640#M12649</guid>
      <dc:creator>johnjester</dc:creator>
      <dc:date>2018-03-09T21:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting token names again</title>
      <link>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344641#M12650</link>
      <description>&lt;P&gt;you can't use &lt;CODE&gt;&amp;lt;set&amp;gt;&lt;/CODE&gt; when doing an eval like this. you'll need to do &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt;. you probably wouldn't want this under &lt;CODE&gt;&amp;lt;init&amp;gt;&lt;/CODE&gt; because you don't initially know what all of those tokens are set as. &lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.2/Viz/tokens#Define_token_filtering_and_formatting"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.2/Viz/tokens#Define_token_filtering_and_formatting&lt;/A&gt;&lt;BR /&gt;
perhaps something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldset&amp;gt;
a bunch of inputs
&amp;lt;change&amp;gt;
&amp;lt;eval token="cond"&amp;gt;("$color$"="all" or "$color$"=color) and ("$type$"="all" or type="$type$") and ("$size$"="all" or size="$size$") and .... &amp;lt;/eval&amp;gt;
&amp;lt;/change&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Mar 2018 21:42:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344641#M12650</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-03-09T21:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting token names again</title>
      <link>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344642#M12651</link>
      <description>&lt;P&gt;I tried to add the change tag inside fieldset but got the warning&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Node &amp;lt;change&amp;gt;  is not allowed here
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit - I realized that I needed to put the change node in each input, and if I use set to change the token using single $, it all works.&lt;/P&gt;

&lt;P&gt;Thanks for getting me on the right track!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 21:59:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344642#M12651</guid>
      <dc:creator>johnjester</dc:creator>
      <dc:date>2018-03-09T21:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting token names again</title>
      <link>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344643#M12652</link>
      <description>&lt;P&gt;Also, I don't believe I want to use the eval node, because that results in the whole expression being evaluated to true or false. I want the full evaluation to wait until the search time on each dashboard element, so that each dashboard element can evaluate the condition for each of the events it is considering.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 22:15:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Substituting-token-names-again/m-p/344643#M12652</guid>
      <dc:creator>johnjester</dc:creator>
      <dc:date>2018-03-09T22:15:42Z</dc:date>
    </item>
  </channel>
</rss>

