<?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: Why is date modifier is not working for the services/search/jobs/export API? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469423#M8445</link>
    <description>&lt;P&gt;No change same result as before, here is the hardcoded info&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'search': 'search source=*kong_access* http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv', 'earliest': '-3h', 'latest': '-1h'}
Request and kwargs is ........
&lt;A href="https://MAHCINENAME:8089/services/search/jobs/export" target="test_blank"&gt;https://MAHCINENAME:8089/services/search/jobs/export&lt;/A&gt;
{'response': []}
search=search+source%3D%2Akong_access%2A+http_apikey+%7C+fields+-+host%2Csource%2Csourcetype%2C+splunk_server%2C+_time%2C+index%2C+_serial&amp;amp;output_mode=csv&amp;amp;earliest=-3h&amp;amp;latest=-1h
{'timeout': None, 'allow_redirects': True, 'verify': False, 'proxies': OrderedDict(), 'stream': True, 'cert': None}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Aug 2019 19:59:40 GMT</pubDate>
    <dc:creator>kotak86</dc:creator>
    <dc:date>2019-08-30T19:59:40Z</dc:date>
    <item>
      <title>Why isn't date modifier working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469419#M8441</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I am written python code to download data from splunk for the given search and given date range but it seems date range is not working- I can see logs which are outside of the date that I've entered.&lt;/P&gt;
&lt;P&gt;Here is my code snippat:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; s = requests.Session()
 r = s.post(url_path, auth=auth, data=data, stream=True, verify=self.verify_cert)
 r.raise_for_status()
 with open(output_file_path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=512):
              if chunk:
                      f.write(chunk)
          f.close()
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is my URL and Json data object:&lt;BR /&gt;URL &lt;A href="https://example-zone-ms.compnay.com:8089/services/search/jobs/export" target="_blank"&gt;https://example-zone-ms.compnay.com:8089/services/search/jobs/export&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{'search': 'search source=*FOO_access* http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv', 'earliest': '08/22/2019:0:0:0', 'latest': '08/22/2019:23:59:59'}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 20:56:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469419#M8441</guid>
      <dc:creator>kotak86</dc:creator>
      <dc:date>2020-06-17T20:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469420#M8442</link>
      <description>&lt;P&gt;Don't think dates will be taken literally, you have to use the epoch converisions&lt;BR /&gt;
strptime(earliest,"%m/%d/%Y") OR pass the number representation of the dates for your time fields&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 11:08:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469420#M8442</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T11:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469421#M8443</link>
      <description>&lt;P&gt;I've updated code to use date object as below but still I am not getting data in my date range but I noticed it's from now - 7 days of data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            earliest = datetime.strptime(self.earliest, "%m/%d/%Y:%H:%M:%S")
            latest = datetime.strptime(self.latest, "%m/%d/%Y:%H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is my Json data&lt;/P&gt;

&lt;P&gt;{'search': 'search source=&lt;EM&gt;kong_access&lt;/EM&gt; http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv', 'earliest': datetime.datetime(2019, 8, 15, 0, 0), 'latest': datetime.datetime(2019, 8, 15, 23, 59, 59)}&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469421#M8443</guid>
      <dc:creator>kotak86</dc:creator>
      <dc:date>2020-09-30T02:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469422#M8444</link>
      <description>&lt;P&gt;hi just to test can you hardcode the datetime to a number format...say -1h ago?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 19:24:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469422#M8444</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T19:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469423#M8445</link>
      <description>&lt;P&gt;No change same result as before, here is the hardcoded info&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'search': 'search source=*kong_access* http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv', 'earliest': '-3h', 'latest': '-1h'}
Request and kwargs is ........
&lt;A href="https://MAHCINENAME:8089/services/search/jobs/export" target="test_blank"&gt;https://MAHCINENAME:8089/services/search/jobs/export&lt;/A&gt;
{'response': []}
search=search+source%3D%2Akong_access%2A+http_apikey+%7C+fields+-+host%2Csource%2Csourcetype%2C+splunk_server%2C+_time%2C+index%2C+_serial&amp;amp;output_mode=csv&amp;amp;earliest=-3h&amp;amp;latest=-1h
{'timeout': None, 'allow_redirects': True, 'verify': False, 'proxies': OrderedDict(), 'stream': True, 'cert': None}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 19:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469423#M8445</guid>
      <dc:creator>kotak86</dc:creator>
      <dc:date>2019-08-30T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469424#M8446</link>
      <description>&lt;P&gt;hi can you remove latest and just use this:&lt;/P&gt;

&lt;P&gt;'earliest':  '1567017000.000000'&lt;/P&gt;

&lt;P&gt;check the space and colon in the json format&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 20:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469424#M8446</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T20:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469425#M8447</link>
      <description>&lt;P&gt;same result no -change - getting data from AUG 24 - AUG 30&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'search': 'search source=*kong_access* http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv', 'earliest': '1567017000.000000'}
Request and kwargs is ........
&lt;A href="https://MACHINENAME:8089/services/search/jobs/export" target="test_blank"&gt;https://MACHINENAME:8089/services/search/jobs/export&lt;/A&gt;
{'response': []}
search=search+source%3D%2Akong_access%2A+http_apikey+%7C+fields+-+host%2Csource%2Csourcetype%2C+splunk_server%2C+_time%2C+index%2C+_serial&amp;amp;output_mode=csv&amp;amp;earliest=1567017000.000000
{'timeout': None, 'allow_redirects': True, 'verify': False, 'proxies': OrderedDict(), 'stream': True, 'cert': None}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 20:31:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469425#M8447</guid>
      <dc:creator>kotak86</dc:creator>
      <dc:date>2019-08-30T20:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469426#M8448</link>
      <description>&lt;P&gt;ok one last try from me &lt;CODE&gt;{'search': 'search source=*FOO_access* earliest=-3d http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv'}&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 21:08:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469426#M8448</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T21:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469427#M8449</link>
      <description>&lt;P&gt;Seems it's working, it means earliest and latest should be part of the search string. &lt;BR /&gt;
Now Only issue I am facing is some timezone related:&lt;BR /&gt;
When I am sending &lt;BR /&gt;
    earliest= 08/24/2019:0:0:0 --&amp;gt; Log start from 08/24/2019:&lt;STRONG&gt;07:00:00&lt;/STRONG&gt;&lt;BR /&gt;
    latest=08/28/2019:23:59:59 --&amp;gt;Log ends to 08/29/2019:&lt;STRONG&gt;07:00:00&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Writing logs to file: /Users/i844276/Kong_log_08_01_2019_08_08_2019/kong_access_log_PROD_US_08_01_2019_0_0_0_08_08_2019_23_59_59.csv
 Inside sessoin py
 {'search': 'search source=*kong_access* earliest=08/01/2019:0:0:0  latest=08/08/2019:23:59:59 http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv'}
 Request and kwargs is ........
 https:MACHINENAME:8089/services/search/jobs/export
 {'response': []}
 search=search+source%3D%2Akong_access%2A+earliest%3D08%2F01%2F2019%3A0%3A0%3A0++latest%3D08%2F08%2F2019%3A23%3A59%3A59+http_apikey+%7C+fields+-+host%2Csource%2Csourcetype%2C+splunk_server%2C+_time%2C+index%2C+_serial&amp;amp;output_mode=csv
 {'timeout': None, 'allow_redirects': True, 'verify': False, 'proxies': OrderedDict(), 'stream': True, 'cert': None}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 23:04:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469427#M8449</guid>
      <dc:creator>kotak86</dc:creator>
      <dc:date>2019-08-30T23:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469428#M8450</link>
      <description>&lt;P&gt;hi @kotak86 &lt;BR /&gt;
Yes and I am sorry , I should have spotted that in the first instance. It was Friday night and late here...hehe&lt;BR /&gt;
Now, coming to the remainder of your issue , it is strange at first glance. Run the job query in splunk UI first and verify that the output is correct , for example - source=&lt;EM&gt;kong_access&lt;/EM&gt; earliest=08/01/2019:0:0:0  latest=08/08/2019:23:59:59&lt;BR /&gt;
Do you see any entries before 7 AM?&lt;BR /&gt;
Consider using the number format for example if i do this &lt;CODE&gt;eval x=strptime("08/27/2019:07:59:59","%m/%d/%Y:%H:%M:%S")&lt;/CODE&gt;&lt;BR /&gt;
x or the time comes to be earliest="1566872999.000000", also consider using quotes in earliest and latest&lt;/P&gt;</description>
      <pubDate>Sat, 31 Aug 2019 07:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469428#M8450</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-31T07:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why is date modifier is not working for the services/search/jobs/export API?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469429#M8451</link>
      <description>&lt;P&gt;I am not getting consistent result - it looks very weird...&lt;BR /&gt;
sending time in epoch ("1566872999.000000")as well date string (""08/27/2019:07:59:59","%m/%d/%Y:%H:%M:%S") works but I am getting different start boundary (means in both file log start from different time) for the following two example.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'search': 'search source=*kong_access* earliest=08/01/2019:0:0:0  latest=08/01/2019:23:59:59 http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv'}



{'search': 'search source=*kong_access* earliest=08/01/2019:0:0:0  latest=08/08/2019:23:59:59 http_apikey | fields - host,source,sourcetype, splunk_server, _time, index, _serial', 'output_mode': 'csv'}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Sep 2019 17:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-isn-t-date-modifier-working-for-the-services-search-jobs/m-p/469429#M8451</guid>
      <dc:creator>kotak86</dc:creator>
      <dc:date>2019-09-09T17:28:38Z</dc:date>
    </item>
  </channel>
</rss>

