<?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: Wrapping TimeRangePicker around DB Connector in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23669#M177473</link>
    <description>&lt;P&gt;If you want to post-filter the results from the DB, you can use &lt;A href="http://splunk-base.splunk.com/answers/75999/" target="_blank"&gt;http://splunk-base.splunk.com/answers/75999/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;To pre-filter, you'll have to use a variation of that technique. In other words, you want to use the TimePicker variables in the SQL query itself. You can do that with the following search language:&lt;/P&gt;

&lt;PRE&gt;| dbquery mydatabase [ stats count | head 1 | addinfo | eval query="SELECT * FROM mytable WHERE ValidFrom &amp;gt;= from_unixtime(".info_min_time.") and ValidFrom &amp;lt; from_unixtime(".info_max_time.")" | fields query | format "" "" "" "" "" ""]&lt;/PRE&gt;
 

&lt;P&gt;&lt;EM&gt;Note:&lt;/EM&gt;&lt;BR /&gt;
&lt;BR /&gt;* from_unixtime is a mysql specific function. &lt;BR /&gt;&lt;BR /&gt;
* If the timepicker is set to "all time" this will generate an error because info_max_time will be "+Infinity". To control for that, you can use an if statement in the eval. i.e.: &lt;PRE&gt;eval query=IF(info_max_time="+Infinity","SELECT WHERE ValidFrom &amp;gt;= info_min_time","SELECT WHERE ValidFrom &amp;gt;= and ValidFrom &amp;lt;")&lt;/PRE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 14:02:23 GMT</pubDate>
    <dc:creator>Dan</dc:creator>
    <dc:date>2020-09-28T14:02:23Z</dc:date>
    <item>
      <title>Wrapping TimeRangePicker around DB Connector</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23667#M177471</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I'd like to wrap a TimeRangePicker around a set of graphs which are pulled out from a DB connector query.&lt;BR /&gt;
I have a field which is being pulled called "ValidFrom" which is a date and time column. This is in every graph.&lt;BR /&gt;
I'd like to match up the TimeRangePicker so that when a range is chosen (last 24 hours, last 7 days, last 4 hours or whatever) that it uses the value taken from the "ValidFrom" field in order to visualise the data.&lt;BR /&gt;
This data is not indexed, it is pulled from the DB connector each time the page is loaded (This is fine for now, as the usage is low, and I understand the data is better indexed in the long term).&lt;/P&gt;

&lt;P&gt;Is there any way to get this to do what I want?&lt;BR /&gt;
I'm already using advanced XML in this view.&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2013 12:43:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23667#M177471</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2013-05-03T12:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Wrapping TimeRangePicker around DB Connector</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23668#M177472</link>
      <description>&lt;P&gt;Does anyone know how to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2013 12:56:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23668#M177472</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2013-05-07T12:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Wrapping TimeRangePicker around DB Connector</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23669#M177473</link>
      <description>&lt;P&gt;If you want to post-filter the results from the DB, you can use &lt;A href="http://splunk-base.splunk.com/answers/75999/" target="_blank"&gt;http://splunk-base.splunk.com/answers/75999/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;To pre-filter, you'll have to use a variation of that technique. In other words, you want to use the TimePicker variables in the SQL query itself. You can do that with the following search language:&lt;/P&gt;

&lt;PRE&gt;| dbquery mydatabase [ stats count | head 1 | addinfo | eval query="SELECT * FROM mytable WHERE ValidFrom &amp;gt;= from_unixtime(".info_min_time.") and ValidFrom &amp;lt; from_unixtime(".info_max_time.")" | fields query | format "" "" "" "" "" ""]&lt;/PRE&gt;
 

&lt;P&gt;&lt;EM&gt;Note:&lt;/EM&gt;&lt;BR /&gt;
&lt;BR /&gt;* from_unixtime is a mysql specific function. &lt;BR /&gt;&lt;BR /&gt;
* If the timepicker is set to "all time" this will generate an error because info_max_time will be "+Infinity". To control for that, you can use an if statement in the eval. i.e.: &lt;PRE&gt;eval query=IF(info_max_time="+Infinity","SELECT WHERE ValidFrom &amp;gt;= info_min_time","SELECT WHERE ValidFrom &amp;gt;= and ValidFrom &amp;lt;")&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:02:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wrapping-TimeRangePicker-around-DB-Connector/m-p/23669#M177473</guid>
      <dc:creator>Dan</dc:creator>
      <dc:date>2020-09-28T14:02:23Z</dc:date>
    </item>
  </channel>
</rss>

