<?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 use multiple text tokens even with no value to one of them. in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311575#M19920</link>
    <description>&lt;P&gt;you need to keep default value of each of the fields while declaring them, keep default value as null and then run the same query it will work.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2017 08:39:23 GMT</pubDate>
    <dc:creator>kunalmao</dc:creator>
    <dc:date>2017-12-04T08:39:23Z</dc:date>
    <item>
      <title>How to use multiple text tokens even with no value to one of them.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311573#M19918</link>
      <description>&lt;P&gt;I have two TEXT fields IP address and Username. I want to create dashboard based on either of the field. tried with "if condition", it did not work.&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
field1=IP_addr&lt;BR /&gt;
field2=user&lt;/P&gt;

&lt;P&gt;| search src_ip=$field1$ OR usr=$field2$ | table src_ip usr&lt;/P&gt;

&lt;P&gt;In above example, if I don't pass value of any one of the fields, I don't get the result.&lt;/P&gt;

&lt;P&gt;How to achieve this? &lt;/P&gt;

&lt;P&gt;PS: It should be easy, however I am new to splunk/programmimg, hence looking for the help.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;BR /&gt;
RS&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:00:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311573#M19918</guid>
      <dc:creator>suchakrajan</dc:creator>
      <dc:date>2020-09-29T17:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use multiple text tokens even with no value to one of them.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311574#M19919</link>
      <description>&lt;P&gt;You could try putting double quotes for IP_addr and user. Otherwise Splunk will thinks it is not a string but a variable.&lt;/P&gt;

&lt;P&gt;Just to be clear you want to take variable from the UI and use it in the search string?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 06:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311574#M19919</guid>
      <dc:creator>valiquet</dc:creator>
      <dc:date>2017-12-04T06:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use multiple text tokens even with no value to one of them.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311575#M19920</link>
      <description>&lt;P&gt;you need to keep default value of each of the fields while declaring them, keep default value as null and then run the same query it will work.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 08:39:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311575#M19920</guid>
      <dc:creator>kunalmao</dc:creator>
      <dc:date>2017-12-04T08:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use multiple text tokens even with no value to one of them.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311576#M19921</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/83813"&gt;@suchakrajan&lt;/a&gt;, since you have an OR condition to be applied for the text box values, you can code the text boxes &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event handlers based on the condition i.e. &lt;/P&gt;

&lt;P&gt;1) either src_ip or username is provided then either &lt;CODE&gt;src_ip=$tokIP$&lt;/CODE&gt; or &lt;CODE&gt;usr=$tokUserName$&lt;/CODE&gt;, &lt;BR /&gt;
2) Both are provided then &lt;CODE&gt;src_ip=$tokIP$ OR usr=$tokUserName$&lt;/CODE&gt; &lt;BR /&gt;
3) Both are empty then &lt;CODE&gt;no search filter to be applied&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="text" token="tokIP" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;IP Address&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition match="len($value$)&amp;gt;0"&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokUserName$) OR len($tokUserName$)=0,"src_ip=".$value$,true(),"usr=".$tokUserName$." OR "."src_ip=".$value$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokUserName$) OR len($tokUserName$)=0," ",true(),"usr=".$tokUserName$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="text" token="tokUserName" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;User Name&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition match="len($value$)&amp;gt;0"&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokIP$) OR len(trim($tokIP$))=0,"usr=".$value$,true(),"src_ip=".$tokIP$." OR "."usr=".$value$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokIP$) OR len(trim($tokIP$))=0," ",true(),"src_ip=".$tokIP$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try the following run anywhere dashboard which set the token on &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event based on &lt;CODE&gt;&amp;lt;condition&amp;gt;&lt;/CODE&gt;and &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt; to set the token for search filter based on above three conditions. PS: &lt;CODE&gt;&amp;lt;init&amp;gt;&lt;/CODE&gt; section is used to empty the search filter token on loading the dashboard (&lt;CODE&gt;&amp;lt;init&amp;gt;&lt;/CODE&gt; section is available in version &lt;CODE&gt;Splunk 6.5&lt;/CODE&gt; onward).&lt;/P&gt;

&lt;P&gt;Use the token &lt;CODE&gt;$tokFilter$&lt;/CODE&gt; in your search which should satisfy all the conditions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Multiple Optional Text Boxes for Search Filter&amp;lt;/label&amp;gt;
  &amp;lt;init&amp;gt;
    &amp;lt;set token="tokFilter"&amp;gt; &amp;lt;/set&amp;gt;
  &amp;lt;/init&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="tokIP" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;IP Address&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition match="len($value$)&amp;gt;0"&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokUserName$) OR len($tokUserName$)=0,"src_ip=".$value$,true(),"usr=".$tokUserName$." OR "."src_ip=".$value$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokUserName$) OR len($tokUserName$)=0," ",true(),"usr=".$tokUserName$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="text" token="tokUserName" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;User Name&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition match="len($value$)&amp;gt;0"&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokIP$) OR len(trim($tokIP$))=0,"usr=".$value$,true(),"src_ip=".$tokIP$." OR "."usr=".$value$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition&amp;gt;
          &amp;lt;eval token="tokFilter"&amp;gt;case(isnull($tokIP$) OR len(trim($tokIP$))=0," ",true(),"src_ip=".$tokIP$)&amp;lt;/eval&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div&amp;gt;
          IP=$tokIP$
        &amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
          User=$tokUserName$
        &amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
          Filter=$tokFilter$
        &amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
          Condition=$tokCondition$
        &amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:03:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311576#M19921</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T17:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use multiple text tokens even with no value to one of them.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311577#M19922</link>
      <description>&lt;P&gt;I have two TEXT fields Object and modifier. I want to create dashboard based on either of the field. tried with "if condition", it did not work.&lt;BR /&gt;
Javascript is also fine&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
field1=object&lt;BR /&gt;
field2=modifier&lt;/P&gt;

&lt;P&gt;| index=name event=$object$ action=$modifier$ |table content group&lt;/P&gt;

&lt;P&gt;--&amp;gt;if both fields are provided no worries&lt;BR /&gt;
--&amp;gt;if both are not provided then  both should be "wildcard(star)"&lt;BR /&gt;
--&amp;gt;if field1 is specified and field2 is not specified then field2 should be "wildcard(star)"&lt;BR /&gt;
--&amp;gt;if field2 is  specified and field1 is not specified then field1 should be "*"&lt;/P&gt;

&lt;P&gt;How to achieve this?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;BR /&gt;
Kranthi M&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 09:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-multiple-text-tokens-even-with-no-value-to-one-of/m-p/311577#M19922</guid>
      <dc:creator>kranthimutyala</dc:creator>
      <dc:date>2019-10-25T09:20:16Z</dc:date>
    </item>
  </channel>
</rss>

