Open shuklashashank opened 4 years ago
@ocervell Do you have any input on this, or should this be closed as stale?
I am experiencing the same issue. I have deployed the cloudfunction Python3.7 on GCP with the following code: main.py
#!/usr/bin/env python3
import base64
import json
from gsuite_exporter.cli import sync_all
def run(data, context):
# Decode Data From Pubsub Message
name = base64.b64decode(data['data']).decode('utf-8')
# Load Data in JSON
dictionary = json.loads(name)
# Parse JSON to Set Variables
project_id = dictionary['PROJECT_ID']
gsuite_admin_user = dictionary['GSUITE_ADMIN_USER']
# Run Log Sync
sync_all(
admin_user=gsuite_admin_user,
api='reports_v1',
applications=['login', 'admin', 'drive', 'mobile', 'token'],
project_id=project_id,
exporter_cls='stackdriver_exporter.StackdriverExporter'
)
requirements.txt
boto3
gsuite_exporter==0.0.4
I get the same error
Exception on /_ah/push-handlers/pubsub/projects/ms--siem--pro--f850/topics/gsuite-admin-logs-topic-trigger [POST]
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/functions_framework/__init__.py", line 171, in view_func
function(data, context)
File "/workspace/main.py", line 40, in run
exporter_cls='stackdriver_exporter.StackdriverExporter'
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gsuite_exporter/cli.py", line 72, in sync_all
start_time = (parser.parse(last_ts) - timedelta(minutes=offset)).isoformat()
TypeError: unsupported type for timedelta minutes component: NoneType
It worked on the first run but then is started to give this error, it seems that is failing on the step where it checks the timestamp of the logs to avoid duplicated entries
I have been looking at the code and on cli.py on the definition I can see that there is a argument name offset which by default set to None. This was causing the error to me. It says on a comment on the code that the argument offset is a str but when I set it as str if failt so I endup setting up as an int and it worket.
I didn't see this argument because I was following the next guide from terraform which should be updated otherwise the module can not be used correctly.
@matthewmarr Do you have any input on this?
Initially, it ran well but when I retry to run it, it gives an error in gsuite-exporter.
below error: