<?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: Python script errors(code 255) and Invalid start time errors in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417349#M50907</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/2012"&gt;@MuS&lt;/a&gt; and &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/109760"&gt;@tommoore&lt;/a&gt;. &lt;/P&gt;

&lt;P&gt;Doesn't this mean for "start_time = end_time - timedelta(days=7)" the start-time will increment forward over time, so you will still pick up new events?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:06:34 GMT</pubDate>
    <dc:creator>becksyboy</dc:creator>
    <dc:date>2020-09-29T23:06:34Z</dc:date>
    <item>
      <title>Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417343#M50901</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;currently testing with this add on, and we are ingesting data successfully. But we are seeing the following errors. Has anyone seen this type of error before with this addon?&lt;/P&gt;

&lt;P&gt;Python script errors(code 255): index=_internal "code 255"&lt;BR /&gt;
ERROR pid=29779 tid=MainThread file=configuration_check.py:run:164 | status="completed" task="confcheck_script_errors" message="msg="A script exited abnormally" input="/opt/splunk/etc/apps/splunk_ta_o365/bin/splunk_ta_o365_management_activity.py" stanza="splunk_ta_o365_management_activity://Audit_AD" status="exited with code 255""&lt;/P&gt;

&lt;P&gt;From one of the logs; /opt/splunk/var/log/splunk/splunk_ta_o365_management_activity_Audit_AD.log&lt;BR /&gt;
O365PortalError: 400:{"error":{"code":"AF20055","message":"Date range for requested content is invalid startTime:2019-01-15T12:58:57 endTime:2019-01-15T13:58:57."}}&lt;BR /&gt;
2019-01-22 12:59:13,409 level=INFO pid=7100 tid=MainThread logger=splunksdc.collector pos=collector.py:run:248 |  | message="Modular input exited." &lt;/P&gt;

&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:51:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417343#M50901</guid>
      <dc:creator>becksyboy</dc:creator>
      <dc:date>2020-09-29T22:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417344#M50902</link>
      <description>&lt;P&gt;We are also seeing this issue - i think i'll raise a case with Splunk&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 03:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417344#M50902</guid>
      <dc:creator>Esky73</dc:creator>
      <dc:date>2019-01-29T03:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417345#M50903</link>
      <description>&lt;P&gt;I just found this post on another thread.  Makes sense because my pulls bomb out exactly 1 week back&lt;/P&gt;

&lt;P&gt;Looks like the limitation is in the O365 Management API that the Splunk app relies on:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://msdn.microsoft.com/office-365/office-365-management-activity-api-reference"&gt;https://msdn.microsoft.com/office-365/office-365-management-activity-api-reference&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;"Content older than 7 days cannot be retrieved."&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 19:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417345#M50903</guid>
      <dc:creator>tommoore</dc:creator>
      <dc:date>2019-02-04T19:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417346#M50904</link>
      <description>&lt;P&gt;Looks like now we need to have the ability to tell the add-on to only go back X days, otherwise it never completes and just keeps pulling in the same weeks worth of data.  I've turned off my inputs until this is figured out &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 19:28:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417346#M50904</guid>
      <dc:creator>tommoore</dc:creator>
      <dc:date>2019-02-04T19:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417347#M50905</link>
      <description>&lt;P&gt;Hi becksyboy, @tommoore &lt;/P&gt;

&lt;P&gt;I had a similar issue where the input stopped unnoticed for more than 2 weeks, and once it was restarted the events were no longer available from the MS API.&lt;/P&gt;

&lt;P&gt;It took me some time to troubleshoot the script/issue, but once I found who and where the checkpoint is accessed it was easy to manually check and update the checkpoint hidden deep inside this &lt;EM&gt;weird&lt;/EM&gt; REST API / KV store construct.&lt;/P&gt;

&lt;P&gt;You can use this command to see the checkpoint:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k &lt;A href="https://127.0.0.1:8089/servicesNS/nobody/TA-MS_O365_Reporting/storage/collections/data/TA_MS_O365_Reporting_checkpointer/" target="test_blank"&gt;https://127.0.0.1:8089/servicesNS/nobody/TA-MS_O365_Reporting/storage/collections/data/TA_MS_O365_Reporting_checkpointer/&lt;/A&gt; -u &amp;lt;username&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And you can use this command to modify the checkpoint:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k --header "Content-Type: application/json" --request POST --data '[ { "state" : "{\"max_date\": \"2018-11-20 18:56:17.772814\"}", "_user" : "nobody", "_key" : "O365_&amp;lt;input name here&amp;gt;_checkpoint"}] ' &lt;A href="https://127.0.0.1:8089/servicesNS/nobody/TA-MS_O365_Reporting/storage/collections/data/TA_MS_O365_Reporting_checkpointer/batch_save" target="test_blank"&gt;https://127.0.0.1:8089/servicesNS/nobody/TA-MS_O365_Reporting/storage/collections/data/TA_MS_O365_Reporting_checkpointer/batch_save&lt;/A&gt; -u &amp;lt;username&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps should you have further issues ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 19:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417347#M50905</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-02-04T19:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417348#M50906</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/2012"&gt;@MuS&lt;/a&gt; ♦  Thanks for the info!  Funny thing.. I actually did it a little simpler, albeit with a sledgehammer. (PS I'm using the &lt;A href="https://splunkbase.splunk.com/app/4055/" target="_blank"&gt;Splunk Add-on for Microsoft Office 365&lt;/A&gt;)&lt;/P&gt;

&lt;P&gt;I edited this file "splunk_ta_o365/bin/splunk_ta_o365/modinputs/management_activity.py"&lt;/P&gt;

&lt;P&gt;Changed the timedelta to 1 day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;119c119
&amp;lt;         start_time = end_time - timedelta(days=7)
---
&amp;gt;         start_time = end_time - timedelta(days=1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now at least it only asks Azure for 24 hrs worth of data at a time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  You could probably get away with 6 days if you wanted to check back that far.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:09:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417348#M50906</guid>
      <dc:creator>tommoore</dc:creator>
      <dc:date>2020-09-29T23:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417349#M50907</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/2012"&gt;@MuS&lt;/a&gt; and &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/109760"&gt;@tommoore&lt;/a&gt;. &lt;/P&gt;

&lt;P&gt;Doesn't this mean for "start_time = end_time - timedelta(days=7)" the start-time will increment forward over time, so you will still pick up new events?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:06:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417349#M50907</guid>
      <dc:creator>becksyboy</dc:creator>
      <dc:date>2020-09-29T23:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417350#M50908</link>
      <description>&lt;P&gt;Yes.. the end-time is always moving so when it runs it uses the "now" as the end-time, and subtracts the days.  As long as you keep it lower than 7 it should complete successfully.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 21:16:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417350#M50908</guid>
      <dc:creator>tommoore</dc:creator>
      <dc:date>2019-02-08T21:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417351#M50909</link>
      <description>&lt;P&gt;I found the issue here&lt;/P&gt;

&lt;P&gt;In file &lt;STRONG&gt;management_activity.py&lt;/STRONG&gt; line 119 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        now = self._now()
        end_time = datetime.utcfromtimestamp(now)
        start_time = end_time - timedelta(days=7)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is that the time of performing all ranges of &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;self._normalize_time_range(start_time, end_time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the latest time-range startTime is greater than 7 days&lt;/P&gt;

&lt;P&gt;The workarround here is to set_up a control in &lt;STRONG&gt;portal.py&lt;/STRONG&gt; line 126&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;--- a/splunk_ta_o365/bin/splunk_ta_o365/common/portal.py
+++ b/splunk_ta_o365/bin/splunk_ta_o365/common/portal.py
@@ -126,6 +126,10 @@ class O365Subscription(O365Portal):
     def list_available_content(self, session, start_time, end_time):
         for _start_time, _end_time in self._normalize_time_range(start_time, end_time):
             items = list()
+            min_start_date = datetime.utcnow() - timedelta(days=7) + timedelta(minutes=1)
+            _start_time = max(min_start_date, _start_time)
+            if _end_time &amp;lt; min_start_date:
+                yield []
             response = self._list_available_content(session, _start_time, _end_time)
             while True:
                 array = response.json()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have put &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    datetime.utcnow() - timedelta(days=7) + timedelta(minutes=1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To be sure that the API will receive a not outdate startTime a avoid traffic impact&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if _end_time &amp;lt; min_start_date:
    yield []
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is here to be sure that the script will not query for an invalid range (if endTime is before the limit of 7 days no need no query this range)&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     _time                                   ContentType    endTime                            startTime
**2019-03-07 11:15:00.105** Audit.Exchange  2019-02-28T12:06:18 **2019-02-28T11:16:00**
2019-03-07 11:14:52.109 Audit.Exchange  2019-02-28T13:06:18 2019-02-28T12:06:18
2019-03-07 11:14:44.943 Audit.Exchange  2019-02-28T14:06:18 2019-02-28T13:06:18
2019-03-07 11:14:39.220 Audit.Exchange  2019-02-28T15:06:18 2019-02-28T14:06:18
2019-03-07 11:14:31.087 Audit.Exchange  2019-02-28T16:06:18 2019-02-28T15:06:18
2019-03-07 11:14:24.550 Audit.Exchange  2019-02-28T17:06:18 2019-02-28T16:06:18
2019-03-07 11:14:23.513 Audit.Exchange  2019-02-28T18:06:18 2019-02-28T17:06:18
2019-03-07 11:14:23.043 Audit.Exchange  2019-02-28T19:06:18 2019-02-28T18:06:18
2019-03-07 11:14:22.062 Audit.Exchange  2019-02-28T20:06:18 2019-02-28T19:06:18
2019-03-07 11:14:20.283 Audit.Exchange  2019-02-28T21:06:18 2019-02-28T20:06:18
2019-03-07 11:14:17.829 Audit.Exchange  2019-02-28T22:06:18 2019-02-28T21:06:18
2019-03-07 11:14:15.291 Audit.Exchange  2019-02-28T23:06:18 2019-02-28T22:06:18
2019-03-07 11:14:13.837 Audit.Exchange  2019-03-01T00:06:18 2019-02-28T23:06:18
2019-03-07 11:14:11.430 Audit.Exchange  2019-03-01T01:06:18 2019-03-01T00:06:18
2019-03-07 11:14:10.963 Audit.Exchange  2019-03-01T02:06:18 2019-03-01T01:06:18
2019-03-07 11:14:09.427 Audit.Exchange  2019-03-01T03:06:18 2019-03-01T02:06:18
2019-03-07 11:14:09.080 Audit.Exchange  2019-03-01T04:06:18 2019-03-01T03:06:18
2019-03-07 11:14:08.340 Audit.Exchange  2019-03-01T05:06:18 2019-03-01T04:06:18
2019-03-07 11:14:06.699 Audit.Exchange  2019-03-01T06:06:18 2019-03-01T05:06:18
2019-03-07 11:14:04.601 Audit.Exchange  2019-03-01T07:06:18 2019-03-01T06:06:18
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 10:23:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417351#M50909</guid>
      <dc:creator>jeanyvesnolen</dc:creator>
      <dc:date>2019-03-07T10:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417352#M50910</link>
      <description>&lt;P&gt;@tommoore - this is exactly what fixed my issue - thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 18:47:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417352#M50910</guid>
      <dc:creator>mannioke</dc:creator>
      <dc:date>2019-03-19T18:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python script errors(code 255) and Invalid start time errors</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417353#M50911</link>
      <description>&lt;P&gt;Hi there, where you able to get answer from Splunk about this?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 16:14:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Python-script-errors-code-255-and-Invalid-start-time-errors/m-p/417353#M50911</guid>
      <dc:creator>layamba</dc:creator>
      <dc:date>2019-10-01T16:14:25Z</dc:date>
    </item>
  </channel>
</rss>

