<?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 earliest / latest not working with simple curl/Python query in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52161#M675</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;the request below returns data from today while I specifically set it to return data from 27th of May to the 29th:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u user:pass &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export" target="test_blank"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;  --data-urlencode search="search * | head 3" -d output_mode=json -d earliest="05/27/2013:0:0:0" -d latest="05/29/2013:0:0:0"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For example the first record returned is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"preview":false,"offset":0,"result":{"_bkt":"main~8~642E60C4-F8A3-448A-89E0-95E274AD3C3F","_cd":"8:54469","_indextime":"1370003005","_raw":"May 31 13:23:23 etc...","_serial":"0","_si":["localhost","main"],"_sourcetype":"syslog","_time":"2013-05-31 13:23:23.000 BST","host":"localhost","index":"main","linecount":"1","source":"/var/log/system.log","sourcetype":"syslog","splunk_server":"localhost"}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Time is: 2013-05-31 13:23:23.000 which is obviously outside the range I specified. I'm probably missing something obvious... what am I doing wrong ?&lt;/P&gt;

&lt;P&gt;EDIT:&lt;/P&gt;

&lt;P&gt;I'm trying now with a simple python script, again, I can't  seem to return the results in the date range I specify. I tried various different ranges (rt-3d, rt-5d, full date, etc...) but nothing works. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request = urllib2.Request("https://localhost:8089/servicesNS/admin/search/search/jobs/export" 
        data = urllib.urlencode({'search': 'search memorystatus | head 3',\
            'output_mode': 'json',\
            'latest':"1369522800",\
            'earliest':"1369436400"}),
    headers = { 'Authorization': ('Splunk %s' %session_key)})
search_results = urllib2.urlopen(request)
print "Full url is: " + request.get_full_url()
print "Data is: " + request.get_data()  
print search_results.read()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The url and data (query) printed in output are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Full url is: &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export" target="test_blank"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;
Data is: search=search+memorystatus+%7C+head+3&amp;amp;earliest=1369436400&amp;amp;output_mode=json&amp;amp;latest=1369522800
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm new to Splunk and I can't really figure out what's wrong, this is driving me crazy... &lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2013 12:34:32 GMT</pubDate>
    <dc:creator>polentaelettric</dc:creator>
    <dc:date>2013-05-31T12:34:32Z</dc:date>
    <item>
      <title>earliest / latest not working with simple curl/Python query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52161#M675</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;the request below returns data from today while I specifically set it to return data from 27th of May to the 29th:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u user:pass &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export" target="test_blank"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;  --data-urlencode search="search * | head 3" -d output_mode=json -d earliest="05/27/2013:0:0:0" -d latest="05/29/2013:0:0:0"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For example the first record returned is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"preview":false,"offset":0,"result":{"_bkt":"main~8~642E60C4-F8A3-448A-89E0-95E274AD3C3F","_cd":"8:54469","_indextime":"1370003005","_raw":"May 31 13:23:23 etc...","_serial":"0","_si":["localhost","main"],"_sourcetype":"syslog","_time":"2013-05-31 13:23:23.000 BST","host":"localhost","index":"main","linecount":"1","source":"/var/log/system.log","sourcetype":"syslog","splunk_server":"localhost"}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Time is: 2013-05-31 13:23:23.000 which is obviously outside the range I specified. I'm probably missing something obvious... what am I doing wrong ?&lt;/P&gt;

&lt;P&gt;EDIT:&lt;/P&gt;

&lt;P&gt;I'm trying now with a simple python script, again, I can't  seem to return the results in the date range I specify. I tried various different ranges (rt-3d, rt-5d, full date, etc...) but nothing works. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request = urllib2.Request("https://localhost:8089/servicesNS/admin/search/search/jobs/export" 
        data = urllib.urlencode({'search': 'search memorystatus | head 3',\
            'output_mode': 'json',\
            'latest':"1369522800",\
            'earliest':"1369436400"}),
    headers = { 'Authorization': ('Splunk %s' %session_key)})
search_results = urllib2.urlopen(request)
print "Full url is: " + request.get_full_url()
print "Data is: " + request.get_data()  
print search_results.read()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The url and data (query) printed in output are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Full url is: &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export" target="test_blank"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;
Data is: search=search+memorystatus+%7C+head+3&amp;amp;earliest=1369436400&amp;amp;output_mode=json&amp;amp;latest=1369522800
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm new to Splunk and I can't really figure out what's wrong, this is driving me crazy... &lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2013 12:34:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52161#M675</guid>
      <dc:creator>polentaelettric</dc:creator>
      <dc:date>2013-05-31T12:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: earliest / latest not working with simple curl/Python query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52162#M676</link>
      <description>&lt;P&gt;Have you tried placing the time range in the search like so:&lt;BR /&gt;
curl -k -u user:pass &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;  --data-urlencode search="search * earliest=05/27/2013:0:0:0 latest=05/29/2013:0:0:0 | head 5" -d output_mode=json&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2013 18:05:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52162#M676</guid>
      <dc:creator>barakreeves</dc:creator>
      <dc:date>2013-05-31T18:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: earliest / latest not working with simple curl/Python query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52163#M677</link>
      <description>&lt;P&gt;that's it ! thank you very much, I didn't know that syntax was possible. They should update the documentation though because the examples are wrong. E.g. in &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.3/RESTAPI/RESTsearch#search.2Fjobs.2Fexport"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.3/RESTAPI/RESTsearch#search.2Fjobs.2Fexport&lt;/A&gt; the curl snippet uses -d earliest="rt-5m" -d latest="rt" which is not working.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2013 20:58:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52163#M677</guid>
      <dc:creator>polentaelettric</dc:creator>
      <dc:date>2013-05-31T20:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: earliest / latest not working with simple curl/Python query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52164#M678</link>
      <description>&lt;P&gt;Glad it worked. I will see if I can get that doc example updated.  One of the great things about Splunk documentation is that they are living documents, constantly being updated.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2013 21:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52164#M678</guid>
      <dc:creator>barakreeves</dc:creator>
      <dc:date>2013-05-31T21:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: earliest / latest not working with simple curl/Python query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52165#M679</link>
      <description>&lt;P&gt;Have you tried these?&lt;BR /&gt;
-d earliest_time="-10m@m" -d latest_time="-5m@m"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:06:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/earliest-latest-not-working-with-simple-curl-Python-query/m-p/52165#M679</guid>
      <dc:creator>cramasta</dc:creator>
      <dc:date>2020-09-28T19:06:26Z</dc:date>
    </item>
  </channel>
</rss>

