<?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 change the query dynamically based on the input in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191685#M11965</link>
    <description>&lt;P&gt;True but how to select which query to execute? I am lookig for kind of "if" clause where I can say if these are the metrics execute this query else execute this query &lt;/P&gt;</description>
    <pubDate>Tue, 24 Mar 2015 01:22:47 GMT</pubDate>
    <dc:creator>xvxt006</dc:creator>
    <dc:date>2015-03-24T01:22:47Z</dc:date>
    <item>
      <title>how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191675#M11955</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying the drill down feature in splunk. It uses a static query to get the sourcetype and then we can drill-down based on the sourcetype selected from the results.  &lt;/P&gt;

&lt;P&gt;Is it possible to use a dynamic query - For example in the text field at the top user can enter a metric, say clientip. Then i would get the count by clientip in the master and when i drill down, it would get detailed metrics. In this way i am not restricting only to sourcetype but i can enter clientip, useragent or any other metric based on the count. &lt;/P&gt;

&lt;P&gt;I am using the below code but drill down is not working..any suggestions please...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;label&amp;gt;In-Page Drilldown with Perma-linking&amp;lt;/label&amp;gt;


    &amp;lt;!--
        Enter a metric to drill down
     --&amp;gt;
    &amp;lt;input type="text" token="metric" searchWhenChanged="true" /&amp;gt;



&amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;!--
        Create an input to store the drilldown value. It will be hidden using custom javascript when
        the dashboard is loaded.
     --&amp;gt;
    &amp;lt;input type="text" token="value" searchWhenChanged="true" /&amp;gt;
&amp;lt;/fieldset&amp;gt;
&amp;lt;row&amp;gt;
    &amp;lt;table id="master"&amp;gt;
        &amp;lt;title&amp;gt;Master&amp;lt;/title&amp;gt;
        &amp;lt;searchString&amp;gt;sourcetype=access_combined_wcookie host=pr*| stats count by $metric$&amp;lt;/searchString&amp;gt;
        &amp;lt;earliestTime&amp;gt;-60m@m&amp;lt;/earliestTime&amp;gt;
        &amp;lt;latestTime&amp;gt;now&amp;lt;/latestTime&amp;gt;
        &amp;lt;!-- Set the type of of drilldown, since we will always consume the same field, use row--&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
        &amp;lt;drilldown&amp;gt;
            &amp;lt;!-- Use set to specify the new token to be created.
                 Use any token from the page or from the click event to produce the value needed. --&amp;gt;
            &amp;lt;set token="value"&amp;gt;$row.metric$&amp;lt;/set&amp;gt;
            &amp;lt;!-- If we also set the form.sourcetype the input will get updated too --&amp;gt;
            &amp;lt;set token="form.value"&amp;gt;$row.metric$&amp;lt;/set&amp;gt;
        &amp;lt;/drilldown&amp;gt;
    &amp;lt;/table&amp;gt;
&amp;lt;/row&amp;gt;
&amp;lt;row&amp;gt;
    &amp;lt;!-- depends is the way we tell the content to only show when the token has a value.
         Hint: use comma separated values if the element requires more than one token. --&amp;gt;
    &amp;lt;chart id="detail" depends="$value$"&amp;gt;
        &amp;lt;title&amp;gt;Detail: $value$&amp;lt;/title&amp;gt;
        &amp;lt;searchTemplate&amp;gt;sourcetype=access_combined_wcookie host=pr* $value$=$value.row$| timechart count&amp;lt;/searchTemplate&amp;gt;
        &amp;lt;earliestTime&amp;gt;-60m@m&amp;lt;/earliestTime&amp;gt;
        &amp;lt;latestTime&amp;gt;now&amp;lt;/latestTime&amp;gt;
    &amp;lt;/chart&amp;gt;
&amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Mar 2015 23:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191675#M11955</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-03-22T23:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191676#M11956</link>
      <description>&lt;P&gt;i have tried this but the row value is not showing up the actual value in the drill down.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;label&amp;gt;In-Page Drilldown with Perma-linking&amp;lt;/label&amp;gt;


    &amp;lt;!--
        Enter a metric to drill down
     --&amp;gt;
    &amp;lt;input type="text" token="metric" searchWhenChanged="true" /&amp;gt;
 &amp;lt;input type="text" token="value" searchWhenChanged="true" /&amp;gt;




&amp;lt;row&amp;gt;
    &amp;lt;table id="master"&amp;gt;
        &amp;lt;title&amp;gt;Master&amp;lt;/title&amp;gt;
        &amp;lt;searchString&amp;gt;sourcetype=access_combined_wcookie host=pr*| stats count by $metric$&amp;lt;/searchString&amp;gt;
        &amp;lt;earliestTime&amp;gt;-60m@m&amp;lt;/earliestTime&amp;gt;
        &amp;lt;latestTime&amp;gt;now&amp;lt;/latestTime&amp;gt;
        &amp;lt;!-- Set the type of of drilldown, since we will always consume the same field, use row--&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
        &amp;lt;drilldown&amp;gt;
            &amp;lt;!-- Use set to specify the new token to be created.
                 Use any token from the page or from the click event to produce the value needed. --&amp;gt;
                &amp;lt;set token="value"&amp;gt;$row.($metric$)$&amp;lt;/set&amp;gt;
            &amp;lt;!-- If we also set the form.sourcetype the input will get updated too --&amp;gt;
            &amp;lt;set token="form.value"&amp;gt;$row.($metric$)$&amp;lt;/set&amp;gt;
        &amp;lt;/drilldown&amp;gt;
    &amp;lt;/table&amp;gt;
&amp;lt;/row&amp;gt;
&amp;lt;row&amp;gt;
    &amp;lt;!-- depends is the way we tell the content to only show when the token has a value.
         Hint: use comma separated values if the element requires more than one token. --&amp;gt;
    &amp;lt;chart id="detail" depends="$value$"&amp;gt;
        &amp;lt;title&amp;gt;Detail: $value$&amp;lt;/title&amp;gt;
        &amp;lt;searchTemplate&amp;gt;sourcetype=access_combined_wcookie host=pr* $metric$=$value$| timechart count&amp;lt;/searchTemplate&amp;gt;
        &amp;lt;earliestTime&amp;gt;-60m@m&amp;lt;/earliestTime&amp;gt;
        &amp;lt;latestTime&amp;gt;now&amp;lt;/latestTime&amp;gt;
    &amp;lt;/chart&amp;gt;
&amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Mar 2015 03:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191676#M11956</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-03-23T03:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191677#M11957</link>
      <description>&lt;P&gt;You can try with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;drilldown&amp;gt;
             &amp;lt;!-- Use set to specify the new token to be created.
                  Use any token from the page or from the click event to produce the value needed. --&amp;gt;
                 &amp;lt;set token="metricname"&amp;gt;$click.value$&amp;lt;/set&amp;gt;
                 &amp;lt;set token="metricvalue"&amp;gt;$row.count$&amp;lt;/set&amp;gt;
             &amp;lt;!-- If we also set the form.sourcetype the input will get updated too --&amp;gt;

             &amp;lt;set token="form.value"&amp;gt;$row.($metric$)$&amp;lt;/set&amp;gt;
         &amp;lt;/drilldown&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and &lt;CODE&gt;sourcetype=access_combined_wcookie host=pr* $metricname$=$metricvalue$| timechart count&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I tried something similar in a test dashboard and it seems to work fine.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 05:49:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191677#M11957</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-03-23T05:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191678#M11958</link>
      <description>&lt;P&gt;hi xvxt006,&lt;BR /&gt;
here's what I think to be able to solve your problem.&lt;BR /&gt;
  at the end of the request from the master, you can add the following line: &lt;CODE&gt;| rename  $metric$ AS field&lt;/CODE&gt;, which will allow you to rename all the fields that you are entering into metric  with the same name &lt;CODE&gt;field&lt;/CODE&gt; that will be easy to manage. Here is the full source code and it works 90 percent&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
&amp;lt;label&amp;gt;In-Page Drilldown with Perma-linking&amp;lt;/label&amp;gt;


 &amp;lt;fieldset submitButton="false"&amp;gt;

    &amp;lt;!--
         Enter a metric to drill down
      --&amp;gt;
     &amp;lt;input type="text" token="metric" searchWhenChanged="true" /&amp;gt;


     &amp;lt;!--
         Create an input to store the drilldown value. It will be hidden using custom javascript when
         the dashboard is loaded.
      --&amp;gt;
     &amp;lt;input type="text" token="value" searchWhenChanged="true" /&amp;gt;
 &amp;lt;/fieldset&amp;gt;
 &amp;lt;row&amp;gt;
     &amp;lt;table id="master"&amp;gt;
         &amp;lt;title&amp;gt;Master: (field=$metric$)&amp;lt;/title&amp;gt;
         &amp;lt;searchString&amp;gt;sourcetype=access_combined_wcookie | stats count by $metric$ |rename $metric$ AS field &amp;lt;/searchString&amp;gt;
         &amp;lt;earliestTime&amp;gt;0&amp;lt;/earliestTime&amp;gt;
         &amp;lt;latestTime&amp;gt;now&amp;lt;/latestTime&amp;gt;
         &amp;lt;!-- Set the type of of drilldown, since we will always consume the same field, use row--&amp;gt;
         &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
         &amp;lt;drilldown&amp;gt;
             &amp;lt;!-- Use set to specify the new token to be created.
                  Use any token from the page or from the click event to produce the value needed. --&amp;gt;
             &amp;lt;set token="value"&amp;gt;$row.field$&amp;lt;/set&amp;gt;
             &amp;lt;!-- If we also set the form.sourcetype the input will get updated too --&amp;gt;
             &amp;lt;set token="form.value"&amp;gt;$row.field$&amp;lt;/set&amp;gt;
         &amp;lt;/drilldown&amp;gt;
     &amp;lt;/table&amp;gt;
 &amp;lt;/row&amp;gt;
 &amp;lt;row&amp;gt;
     &amp;lt;!-- depends is the way we tell the content to only show when the token has a value.
          Hint: use comma separated values if the element requires more than one token. --&amp;gt;
     &amp;lt;chart id="detail" depends="$value$"&amp;gt;
         &amp;lt;title&amp;gt;Detail: $value$&amp;lt;/title&amp;gt;
         &amp;lt;searchTemplate&amp;gt;sourcetype=access_combined_wcookie $metric$=$value$ | timechart count&amp;lt;/searchTemplate&amp;gt;
         &amp;lt;earliestTime&amp;gt;0&amp;lt;/earliestTime&amp;gt;
         &amp;lt;latestTime&amp;gt;now&amp;lt;/latestTime&amp;gt;
     &amp;lt;/chart&amp;gt;
 &amp;lt;/row&amp;gt;

&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you use splunk 6.2.x, don't forget to replace earliestTime or latestTime with earliest and latest&lt;BR /&gt;
try it and let me know if this solved your problem.&lt;BR /&gt;
please forgive my english.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 10:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191678#M11958</guid>
      <dc:creator>gyslainlatsa</dc:creator>
      <dc:date>2015-03-23T10:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191679#M11959</link>
      <description>&lt;P&gt;Thanks both the solutions are working.  One question, based on the metric i have selected, can change the query too? meaning if i have response time, count would not make sense right. i would want timechart avg(time) something like that. &lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 12:50:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191679#M11959</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-03-23T12:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191680#M11960</link>
      <description>&lt;P&gt;Thank you. This worked with small change for me. sourcetype=access_combined_wcookie host=pr* $metric$="$metricname$"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191680#M11960</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2020-09-28T19:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191681#M11961</link>
      <description>&lt;P&gt;Looks like i could not award points if i don't select it as an answer. I wish i could do that. Anyways thanks for your help. &lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 13:00:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191681#M11961</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-03-23T13:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191682#M11962</link>
      <description>&lt;P&gt;changed to an answer instead..&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 23:06:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191682#M11962</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-03-23T23:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191683#M11963</link>
      <description>&lt;P&gt;i also have another question along this...if i want to change the query based on the metric..for example if i have a metric which uses avg instead of a count (for example response time), is it possible to change the query to use timechart avg(metric) instead of timechart count? &lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 23:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191683#M11963</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-03-23T23:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191684#M11964</link>
      <description>&lt;P&gt;&lt;CODE&gt;timechart avg($metric$)&lt;/CODE&gt; should work just fine if thats what you are looking for.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 23:44:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191684#M11964</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-03-23T23:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191685#M11965</link>
      <description>&lt;P&gt;True but how to select which query to execute? I am lookig for kind of "if" clause where I can say if these are the metrics execute this query else execute this query &lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 01:22:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191685#M11965</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-03-24T01:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the query dynamically based on the input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191686#M11966</link>
      <description>&lt;P&gt;hi xvxt006,&lt;BR /&gt;
this is my email &lt;CODE&gt;gyslainko@gmail.com&lt;/CODE&gt;, I come from Cameroon and I'm going to look at what you specify below. in case of further collaboration, you can write me.&lt;BR /&gt;
please forgive my english.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 12:54:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-change-the-query-dynamically-based-on-the-input/m-p/191686#M11966</guid>
      <dc:creator>gyslainlatsa</dc:creator>
      <dc:date>2015-03-24T12:54:34Z</dc:date>
    </item>
  </channel>
</rss>

