Skip to content
Snippets Groups Projects
Unverified Commit f81fb7f3 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

kibana_fetch_logs: Adapt according to current indexed data

Prior to this, the args/kwargs/exception were directly retrieved from
the swh_logging_{args|kwargs|exception} field. This is no longer the
case.

What possibly changed this was the migration between banco to the
elasticsearch cluster... When we were using banco, logstash might have
transformed the data. I no longer think we use a logstash to push the
logs?
parent 616c5a49
No related branches found
No related tags found
No related merge requests found
......@@ -113,33 +113,45 @@ class KibanaFetchLog(SWHConfig):
if not hits:
return {}
args_keys = []
kwargs_keys = []
all_data = []
last_sort_time = None
for data in hits:
last_sort_time = data['sort'][0]
source = data['_source']
_data = {}
swh_logging_args_args = source.get('swh_logging_args_args')
if swh_logging_args_args:
_data['args'] = ast.literal_eval(swh_logging_args_args)
swh_logging_args_kwargs = source.get('swh_logging_args_kwargs')
if swh_logging_args_kwargs:
_data['kwargs'] = ast.literal_eval(swh_logging_args_kwargs)
exception = source.get('swh_logging_args_exc')
if exception:
_data['exception'] = exception
if not _data:
message = source.get('message')
if message:
_data = {
'args': {},
'kwargs': {},
'exception': message
}
_data = {
'args': [],
'kwargs': {},
}
source_keys = source.keys()
# filtering args
if not args_keys:
for k in (k for k in source_keys if '_args_' in k):
args_keys.append(k)
# and kwargs
if not kwargs_keys:
for k in (k for k in source_keys if '_kwargs_' in k):
kwargs_keys.append(k)
for _arg in args_keys:
args_value = source.get(_arg)
if args_value:
_data['args'].append(args_value)
for _kwarg in kwargs_keys:
kwargs_value = source.get(_kwarg)
if kwargs_value:
kwargs_key = _kwarg.split('swh_task_kwargs_')[1]
_data['kwargs'][kwargs_key] = kwargs_value
message = source.get('message')
if message:
_data['exception'] = message
if _data:
all_data.append(_data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment