<?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: declaring a variable in splunk dasboard and make available to all searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288281#M87272</link>
    <description>&lt;P&gt;tks both answers are good &lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2017 01:45:27 GMT</pubDate>
    <dc:creator>HattrickNZ</dc:creator>
    <dc:date>2017-11-28T01:45:27Z</dc:date>
    <item>
      <title>declaring a variable in splunk dasboard and make available to all searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288278#M87269</link>
      <description>&lt;P&gt;I have a splunk dashboard with multiple panels/searches. My sample dashboard below.&lt;/P&gt;

&lt;P&gt;I want to be able to declare a variable at the top that is available to every search below, on the dashboard.&lt;/P&gt;

&lt;P&gt;Can this be done in advanced XML. Appreciate any advise.&lt;/P&gt;

&lt;P&gt;My sample dashboard. For example, I am using &lt;CODE&gt;VaribleX = 500&lt;/CODE&gt; as the variable to be shared across the dashboard.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
    ...

VaribleX = 500
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;device=BRT01KPR component="GigabitEthernet1_0_1.200" Mbps&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
          search 1 ... | timechart span=d sum(VariableX)
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-1d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;@d&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
        ...
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;device=BRT01KPR component="GigabitEthernet1_0_1.200" Mbps&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
          search 1 ... | timechart span=d sum(VariableX)
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-1d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;@d&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
        ...
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;

...

  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;device=BRT01KPR component="GigabitEthernet1_0_1.200" Mbps&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
          search 1 ... | timechart span=d sum(VariableX)
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-1d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;@d&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
        ...
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;device=BRT01KPR component="GigabitEthernet1_0_1.200" Mbps&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
          search 1 ... | timechart span=d sum(VariableX)
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-1d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;@d&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
        ...
      &amp;lt;/table&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>Thu, 16 Nov 2017 20:12:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288278#M87269</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2017-11-16T20:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a variable in splunk dasboard and make available to all searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288279#M87270</link>
      <description>&lt;P&gt;I believe you want to pass value dynamically..! &lt;BR /&gt;
You can do this using simple XML and you have started correctly by selecting form. Now you should be able to select input type text from "Add Input" and give label for your variable(My Variable), variable name (VariableX), and default value(500) as optional. Then use your variable in dashboard code as $VariableX$ to replace user input.&lt;BR /&gt;
your input should look something like shown in screenshot and your search like below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
           search 1 ... Field=$VariableX$ | .... 
&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3868iCC59F16A462658CF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 21:07:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288279#M87270</guid>
      <dc:creator>sgundeti</dc:creator>
      <dc:date>2017-11-16T21:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a variable in splunk dasboard and make available to all searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288280#M87271</link>
      <description>&lt;P&gt;If you don't want users selecting that value via an input, you can just use the init tag to set it on dashboard load.  Here's a simple example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Init Token&amp;lt;/label&amp;gt;
  &amp;lt;init&amp;gt;
    &amp;lt;set token="variableX"&amp;gt;splunkd&amp;lt;/set&amp;gt;
  &amp;lt;/init&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;|  tstats count where index=_internal sourcetype=$variableX$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 21:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288280#M87271</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2017-11-16T21:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a variable in splunk dasboard and make available to all searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288281#M87272</link>
      <description>&lt;P&gt;tks both answers are good &lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 01:45:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288281#M87272</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2017-11-28T01:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a variable in splunk dasboard and make available to all searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288282#M87273</link>
      <description>&lt;P&gt;tks both answers are good &lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 01:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288282#M87273</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2017-11-28T01:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a variable in splunk dasboard and make available to all searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288283#M87274</link>
      <description>&lt;P&gt;&lt;CODE&gt;&amp;lt;form hideFilters="true"&amp;gt;&lt;/CODE&gt; to hide the filters &lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 01:50:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/declaring-a-variable-in-splunk-dasboard-and-make-available-to/m-p/288283#M87274</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2017-11-28T01:50:03Z</dc:date>
    </item>
  </channel>
</rss>

