<?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: Custom Splunk query with relative time in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322152#M20736</link>
    <description>&lt;P&gt;Another thing you need to explain about -15 min. Is it 15 minutes prior to the DateTime value selected as Label in the Dropdown?&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2017 08:41:45 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-02-22T08:41:45Z</dc:date>
    <item>
      <title>Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322150#M20734</link>
      <description>&lt;P&gt;Hi guys,&lt;BR /&gt;
I'm trying to create a custom dashboard.&lt;BR /&gt;
I've added a DropDown input with the following parameters:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;token failureId&lt;/LI&gt;
&lt;LI&gt;query= myquery&lt;/LI&gt;
&lt;LI&gt;Field for label= Date&lt;/LI&gt;
&lt;LI&gt;Field for Value= FailureID&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I would like to create a graph line where the time range is between: ($failureId$/1000)-15minutes and  ($failureId$/1000)&lt;/P&gt;

&lt;P&gt;how can i configure the chart panel to perform this query?&lt;BR /&gt;
thanks &lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 07:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322150#M20734</guid>
      <dc:creator>faustf</dc:creator>
      <dc:date>2017-02-22T07:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322151#M20735</link>
      <description>&lt;P&gt;I am not sure what you mean by &lt;CODE&gt;($failureId$/1000)&lt;/CODE&gt;&lt;BR /&gt;
Do you mean that your failure id is a large number eg 37000, and you are trying to convert this to 37?&lt;BR /&gt;
or - are you trying to trying to divide the number of occurrences of a given failure id by 1000?&lt;BR /&gt;
Whilst i am asking questions, what is the significance of -15 from a failure id?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 08:31:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322151#M20735</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-22T08:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322152#M20736</link>
      <description>&lt;P&gt;Another thing you need to explain about -15 min. Is it 15 minutes prior to the DateTime value selected as Label in the Dropdown?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 08:41:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322152#M20736</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-02-22T08:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322153#M20737</link>
      <description>&lt;P&gt;The failureID is a TimeStamp like this: 1487753100000000 but to let Splunk treat this timestamp I have to perform this  division: 1487749956/1000000  (sorry it is not 1000 but 1000000)&lt;/P&gt;

&lt;P&gt;For example the following is a query that I created and it's working&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype="csv" Resource=myres  myfield=* FailureID=*  | eval _time=(FailureID/1000000) | table _time, myfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I want to get all the logs that are between my (FailureIDTimestamp - 15 minutes) and  FailureIDTimestamp. &lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 08:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322153#M20737</guid>
      <dc:creator>faustf</dc:creator>
      <dc:date>2017-02-22T08:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322154#M20738</link>
      <description>&lt;P&gt;Yes, the user select the failureID  (that is my type of timestamp) in the dropdown (the token of the dropdown is $failureId$) and I what to perform a query to create a line chart using this time range: [$failureId$/1000000 - 15m,  $failureId$/1000000 ]&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 08:51:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322154#M20738</guid>
      <dc:creator>faustf</dc:creator>
      <dc:date>2017-02-22T08:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322155#M20739</link>
      <description>&lt;P&gt;Assuming your running Splunk 6.3 or newer, you can use the &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; element on the dropdown to set the time values accordingly. The following assumes you are using a global time picker atop of the dashboard. If you are using a timepicker with a specific name, you will need to change the token names to &lt;CODE&gt;form.&amp;lt;TIME_TOKEN_NAME&amp;gt;.earliest&lt;/CODE&gt; and &lt;CODE&gt;form.&amp;lt;TIME_TOKEN_NAME&amp;gt;.latest&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input token="failureId" type="dropdown"&amp;gt;
   ...
  &amp;lt;change&amp;gt;
    &amp;lt;condition label="*"&amp;gt;
      &amp;lt;eval token="earliest"&amp;gt;round('value'/1000000, 3) - 15*60&amp;lt;/set&amp;gt;
      &amp;lt;eval token="latest"&amp;gt;round('value'/1000000, 3)&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt;
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2017 09:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322155#M20739</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-02-22T09:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322156#M20740</link>
      <description>&lt;P&gt;This seems interesting but I don't need to modify the dropdown, instead, I need to modify the query that create the line chart based on the value selected in the dropDown:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
      &amp;lt;input type="dropdown" token="failureID"&amp;gt;
        &amp;lt;label&amp;gt;FailureID&amp;lt;/label&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;Date&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;FailureID&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;myquery&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=myindex ALARM="ALARM" | timechart count&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$failureID$/1000 - 15 minutes&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$failureID$/1000&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="charting.chart"&amp;gt;line&amp;lt;/option&amp;gt;
      &amp;lt;/chart&amp;gt;
    &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is it possible?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 10:14:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322156#M20740</guid>
      <dc:creator>faustf</dc:creator>
      <dc:date>2017-02-22T10:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322157#M20741</link>
      <description>&lt;P&gt;This is working &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=myindex ALARM="ALARM" | timechart count&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$failureID$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="charting.chart"&amp;gt;line&amp;lt;/option&amp;gt;
&amp;lt;/chart&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I need to subtract -15 minute from  &lt;CODE&gt;&amp;lt;earliest&amp;gt;$failureID$&amp;lt;/earliest&amp;gt;&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 10:29:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322157#M20741</guid>
      <dc:creator>faustf</dc:creator>
      <dc:date>2017-02-22T10:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322158#M20742</link>
      <description>&lt;P&gt;The example I gave you should do what you want because it is directly modifying the search time period for the chart. I suggsest you try what I posted after you remove the &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; from the &lt;CODE&gt;chart&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 10:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322158#M20742</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-02-22T10:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322159#M20743</link>
      <description>&lt;P&gt;You would need to code Dropdown change event because you are trying to perform calculation on selection of value in Dropdown. &lt;/P&gt;

&lt;P&gt;You also need to &lt;BR /&gt;
 - Either provide a default value for Dropdown and enable search on change to allow your dashboard to load for the first time. &lt;BR /&gt;
 - Or else set depends in the second panel on the tokens $Earliest$ and $Latest$ because for the first time Panel can not be displayed without these values. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;change&amp;gt;
    &amp;lt;eval token="Earliest"&amp;gt;relative_time($value$/1000000,"-15m")&amp;lt;/eval&amp;gt;
    &amp;lt;eval token="Latest"&amp;gt;$value$/1000000&amp;lt;/eval&amp;gt;
  &amp;lt;/change&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you have set the token in the Dropdown on selecting/changing dropdown value, you can use the same in your second panel as you have mentioned before... i.e. by adding following to your search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      &amp;lt;earliest&amp;gt;$Earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$Latest$&amp;lt;/latest&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2017 10:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322159#M20743</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-02-22T10:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Splunk query with relative time</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322160#M20744</link>
      <description>&lt;P&gt;you are right it worked.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 11:03:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Splunk-query-with-relative-time/m-p/322160#M20744</guid>
      <dc:creator>faustf</dc:creator>
      <dc:date>2017-02-22T11:03:46Z</dc:date>
    </item>
  </channel>
</rss>

