mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #6825 from ryanpetrello/test-other-loggers
allow users to test log aggregration if `awx` isn't in the loggers list Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
5d40cf7635
@ -170,7 +170,13 @@ class SettingLoggingTest(GenericAPIView):
|
||||
return Response({'error': 'Logging not enabled'}, status=status.HTTP_409_CONFLICT)
|
||||
|
||||
# Send test message to configured logger based on db settings
|
||||
logging.getLogger('awx').error('AWX Connection Test Message')
|
||||
try:
|
||||
default_logger = settings.LOG_AGGREGATOR_LOGGERS[0]
|
||||
if default_logger != 'awx':
|
||||
default_logger = f'awx.analytics.{default_logger}'
|
||||
except IndexError:
|
||||
default_logger = 'awx'
|
||||
logging.getLogger(default_logger).error('AWX Connection Test Message')
|
||||
|
||||
hostname = getattr(settings, 'LOG_AGGREGATOR_HOST', None)
|
||||
protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', None)
|
||||
|
||||
@ -127,14 +127,14 @@ class LogstashFormatter(LogstashFormatterBase):
|
||||
pass # best effort here, if it's not valid JSON, then meh
|
||||
return raw_data
|
||||
elif kind == 'system_tracking':
|
||||
data = copy(raw_data['ansible_facts'])
|
||||
data = copy(raw_data.get('ansible_facts', {}))
|
||||
else:
|
||||
data = copy(raw_data)
|
||||
if isinstance(data, str):
|
||||
data = json.loads(data)
|
||||
data_for_log = {}
|
||||
|
||||
if kind == 'job_events':
|
||||
if kind == 'job_events' and raw_data.get('python_objects', {}).get('job_event'):
|
||||
job_event = raw_data['python_objects']['job_event']
|
||||
for field_object in job_event._meta.fields:
|
||||
|
||||
@ -165,10 +165,10 @@ class LogstashFormatter(LogstashFormatterBase):
|
||||
data['ansible_python'].pop('version_info', None)
|
||||
|
||||
data_for_log['ansible_facts'] = data
|
||||
data_for_log['ansible_facts_modified'] = raw_data['ansible_facts_modified']
|
||||
data_for_log['inventory_id'] = raw_data['inventory_id']
|
||||
data_for_log['host_name'] = raw_data['host_name']
|
||||
data_for_log['job_id'] = raw_data['job_id']
|
||||
data_for_log['ansible_facts_modified'] = raw_data.get('ansible_facts_modified')
|
||||
data_for_log['inventory_id'] = raw_data.get('inventory_id')
|
||||
data_for_log['host_name'] = raw_data.get('host_name')
|
||||
data_for_log['job_id'] = raw_data.get('job_id')
|
||||
elif kind == 'performance':
|
||||
def convert_to_type(t, val):
|
||||
if t is float:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user