<?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 REST API: DBX: Specify time range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/538832#M152366</link>
    <description>&lt;P&gt;Need to run a&amp;nbsp;&lt;STRONG&gt;dbxquery&lt;/STRONG&gt; command via the REST API, and having trouble defining the search's time range in that context. Below I demonstrate how the queries appear in the web UI, versus the commandline with&amp;nbsp;&lt;STRONG&gt;curl&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Either the query is invalid because&amp;nbsp;&lt;STRONG&gt;| dbxquery&lt;/STRONG&gt; needs to be at the beginning of the query, or no results are returned when appending&amp;nbsp;&lt;STRONG&gt; | search earliest=-1day latest=now&lt;/STRONG&gt; to the end of the query.&lt;/P&gt;&lt;P&gt;How can I correctly specify a time range when using&amp;nbsp;&lt;STRONG&gt;| dbxquery&lt;/STRONG&gt; via REST API?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spk-dbx-ui1.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12836i28A254EC70BABC53/image-size/large?v=v2&amp;amp;px=999" role="button" title="spk-dbx-ui1.PNG" alt="spk-dbx-ui1.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spk-dbx-ui2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12838i8D4596A41D9B46E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="spk-dbx-ui2.PNG" alt="spk-dbx-ui2.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spk-dbx-ui3.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12837i28AF2C7C8A7E1FA4/image-size/large?v=v2&amp;amp;px=999" role="button" title="spk-dbx-ui3.PNG" alt="spk-dbx-ui3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[root@host ~]# curl -u user:password -k https://192.168.xx.xxx:xxxx/services/search/jobs/export --data-urlencode search='seary connection="xxx" query="SELECT  (SELECT sum(bytes) FROM dba_data_files)+  (SELECT sum(bytes) FROM dba_temp_files)-  (SELECT sum(bytes) FROM dba_
&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;response&amp;gt;&amp;lt;messages&amp;gt;&amp;lt;msg type="FATAL"&amp;gt;Error in 'dbxquery' command: This command must be the first command of a search.&amp;lt;/msg&amp;gt;&amp;lt;/messages&amp;gt;&amp;lt;/response&amp;gt;

[root@host ~]# curl -u user:password -k https://192.168.xx.xxx:xxxx/services/search/jobs/export --data-urlencode search='| dT  (SELECT sum(bytes) FROM dba_data_files)+  (SELECT sum(bytes) FROM dba_temp_files)-  (SELECT sum(bytes) FROM dba_free_space) total_size FROM dual;
&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;results preview='0'&amp;gt;
&amp;lt;meta&amp;gt;
&amp;lt;fieldOrder&amp;gt;
&amp;lt;field&amp;gt;TOTAL_SIZE&amp;lt;/field&amp;gt;
&amp;lt;/fieldOrder&amp;gt;
&amp;lt;/meta&amp;gt;
&amp;lt;messages&amp;gt;
  &amp;lt;msg type="DEBUG"&amp;gt;Configuration initialization for /opt/splunk/etc took 15ms when dispatching a search (search ID: 1612554968.128577)&amp;lt;/msg&amp;gt;
  &amp;lt;msg type="DEBUG"&amp;gt;The 'dbxquery' command is implemented as an external script and may cause the search to be significantly slower.&amp;lt;/msg&amp;gt;
  &amp;lt;msg type="DEBUG"&amp;gt;search context: user="reporting", app="search", bs-pathname="/opt/splunk/etc"&amp;lt;/msg&amp;gt;
&amp;lt;/messages&amp;gt;

&amp;lt;/results&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2021 20:52:49 GMT</pubDate>
    <dc:creator>mxanareckless</dc:creator>
    <dc:date>2021-02-05T20:52:49Z</dc:date>
    <item>
      <title>REST API: DBX: Specify time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/538832#M152366</link>
      <description>&lt;P&gt;Need to run a&amp;nbsp;&lt;STRONG&gt;dbxquery&lt;/STRONG&gt; command via the REST API, and having trouble defining the search's time range in that context. Below I demonstrate how the queries appear in the web UI, versus the commandline with&amp;nbsp;&lt;STRONG&gt;curl&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Either the query is invalid because&amp;nbsp;&lt;STRONG&gt;| dbxquery&lt;/STRONG&gt; needs to be at the beginning of the query, or no results are returned when appending&amp;nbsp;&lt;STRONG&gt; | search earliest=-1day latest=now&lt;/STRONG&gt; to the end of the query.&lt;/P&gt;&lt;P&gt;How can I correctly specify a time range when using&amp;nbsp;&lt;STRONG&gt;| dbxquery&lt;/STRONG&gt; via REST API?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spk-dbx-ui1.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12836i28A254EC70BABC53/image-size/large?v=v2&amp;amp;px=999" role="button" title="spk-dbx-ui1.PNG" alt="spk-dbx-ui1.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spk-dbx-ui2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12838i8D4596A41D9B46E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="spk-dbx-ui2.PNG" alt="spk-dbx-ui2.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spk-dbx-ui3.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12837i28AF2C7C8A7E1FA4/image-size/large?v=v2&amp;amp;px=999" role="button" title="spk-dbx-ui3.PNG" alt="spk-dbx-ui3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[root@host ~]# curl -u user:password -k https://192.168.xx.xxx:xxxx/services/search/jobs/export --data-urlencode search='seary connection="xxx" query="SELECT  (SELECT sum(bytes) FROM dba_data_files)+  (SELECT sum(bytes) FROM dba_temp_files)-  (SELECT sum(bytes) FROM dba_
&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;response&amp;gt;&amp;lt;messages&amp;gt;&amp;lt;msg type="FATAL"&amp;gt;Error in 'dbxquery' command: This command must be the first command of a search.&amp;lt;/msg&amp;gt;&amp;lt;/messages&amp;gt;&amp;lt;/response&amp;gt;

[root@host ~]# curl -u user:password -k https://192.168.xx.xxx:xxxx/services/search/jobs/export --data-urlencode search='| dT  (SELECT sum(bytes) FROM dba_data_files)+  (SELECT sum(bytes) FROM dba_temp_files)-  (SELECT sum(bytes) FROM dba_free_space) total_size FROM dual;
&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;results preview='0'&amp;gt;
&amp;lt;meta&amp;gt;
&amp;lt;fieldOrder&amp;gt;
&amp;lt;field&amp;gt;TOTAL_SIZE&amp;lt;/field&amp;gt;
&amp;lt;/fieldOrder&amp;gt;
&amp;lt;/meta&amp;gt;
&amp;lt;messages&amp;gt;
  &amp;lt;msg type="DEBUG"&amp;gt;Configuration initialization for /opt/splunk/etc took 15ms when dispatching a search (search ID: 1612554968.128577)&amp;lt;/msg&amp;gt;
  &amp;lt;msg type="DEBUG"&amp;gt;The 'dbxquery' command is implemented as an external script and may cause the search to be significantly slower.&amp;lt;/msg&amp;gt;
  &amp;lt;msg type="DEBUG"&amp;gt;search context: user="reporting", app="search", bs-pathname="/opt/splunk/etc"&amp;lt;/msg&amp;gt;
&amp;lt;/messages&amp;gt;

&amp;lt;/results&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 20:52:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/538832#M152366</guid>
      <dc:creator>mxanareckless</dc:creator>
      <dc:date>2021-02-05T20:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: REST API: DBX: Specify time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/540697#M152995</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223382"&gt;@mxanareckless&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used constructs similar to this in the past:&lt;/P&gt;&lt;P&gt;| dbxquery connection="my_connection" query="SELET * FROM tbl WHERE t BETWEEN ".&lt;BR /&gt;[| makeresults&lt;BR /&gt;| addinfo&lt;BR /&gt;| eval t="\"'".strftime(info_min_time, "%F %T")."' AND '".strftime(info_max_time, "%F %T")."'\""&lt;BR /&gt;| return $t]&lt;/P&gt;&lt;P&gt;You'll want to modify appropriately with TO_DATE, TO_TIMESTAMP, etc. for Oracle.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 05:37:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/540697#M152995</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-02-21T05:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: REST API: DBX: Specify time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/540895#M153083</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49493"&gt;@tscroggins&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your response. How can I integrate this solution with my current query? I am not well versed in Oracle DB and am only providing Splunk queries for that team.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| dbxquery connection="helps" query="select (select sum(bytes) from dba_data_files)+(select sum(bytes) from dba_temp_files)-(select sum(bytes) from dba_free_space) total_size from dual;"&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 18:22:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/540895#M153083</guid>
      <dc:creator>mxanareckless</dc:creator>
      <dc:date>2021-02-22T18:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: REST API: DBX: Specify time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/540951#M153112</link>
      <description>&lt;P&gt;The DBA_DATA_FILES, DBA_TEMP_FILES, and DBA_FREE_SPACE views do not contain date columns.&lt;/P&gt;&lt;P&gt;If your Oracle DBAs want to track changes to those views over time, a more appropriate solution would be e.g. a daily DB Connect input with the timestamp set to the current time in the input configuration.&lt;/P&gt;&lt;P&gt;After the input is in place, you can just search the data in Splunk:&lt;/P&gt;&lt;P&gt;index=foo sourcetype=bar&lt;BR /&gt;| timechart span=1d values(total_size)&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 03:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REST-API-DBX-Specify-time-range/m-p/540951#M153112</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-02-23T03:37:39Z</dc:date>
    </item>
  </channel>
</rss>

