allow for reloading of logging settings via CTiT

This commit is contained in:
AlanCoding
2016-11-30 16:52:47 -05:00
parent 37ef4e8bc8
commit 3643d9c06b
2 changed files with 21 additions and 5 deletions

View File

@@ -40,6 +40,10 @@ def handle_setting_change(key, for_delete=False):
value=getattr(settings, setting_key, None), value=getattr(settings, setting_key, None),
enter=not bool(for_delete), enter=not bool(for_delete),
) )
# TODO: Move logic to task to run on all cluster nodes
if setting_key.startswith('LOG_AGGREGATOR_'):
settings.LOGGING_CONFIG = None
logging.config.dictConfig(settings.LOGGING)
@receiver(post_save, sender=Setting) @receiver(post_save, sender=Setting)

View File

@@ -227,6 +227,7 @@ register(
register( register(
'LOG_AGGREGATOR_HOST', 'LOG_AGGREGATOR_HOST',
field_class=fields.CharField, field_class=fields.CharField,
allow_null=True,
label=_('Logging Aggregator Receiving Host'), label=_('Logging Aggregator Receiving Host'),
help_text=_('External host maintain a log collector to send logs to'), help_text=_('External host maintain a log collector to send logs to'),
category=_('Logging'), category=_('Logging'),
@@ -234,7 +235,8 @@ register(
) )
register( register(
'LOG_AGGREGATOR_PORT', 'LOG_AGGREGATOR_PORT',
field_class=fields.CharField, field_class=fields.IntegerField,
allow_null=True,
label=_('Logging Aggregator Receiving Port'), label=_('Logging Aggregator Receiving Port'),
help_text=_('Port that the log collector is listening on'), help_text=_('Port that the log collector is listening on'),
category=_('Logging'), category=_('Logging'),
@@ -242,7 +244,9 @@ register(
) )
register( register(
'LOG_AGGREGATOR_TYPE', 'LOG_AGGREGATOR_TYPE',
field_class=fields.CharField, field_class=fields.ChoiceField,
choices=['logstash', 'splunk', 'loggly', 'sumologic', 'other'],
allow_null=True,
label=_('Logging Aggregator Type: Logstash, Loggly, Datadog, etc'), label=_('Logging Aggregator Type: Logstash, Loggly, Datadog, etc'),
help_text=_('The type of log aggregator service to format messages for'), help_text=_('The type of log aggregator service to format messages for'),
category=_('Logging'), category=_('Logging'),
@@ -251,6 +255,7 @@ register(
register( register(
'LOG_AGGREGATOR_USERNAME', 'LOG_AGGREGATOR_USERNAME',
field_class=fields.CharField, field_class=fields.CharField,
allow_null=True,
label=_('Logging Aggregator Username to Authenticate With'), label=_('Logging Aggregator Username to Authenticate With'),
help_text=_('Username for Logstash or others (basic auth)'), help_text=_('Username for Logstash or others (basic auth)'),
category=_('Logging'), category=_('Logging'),
@@ -259,6 +264,7 @@ register(
register( register(
'LOG_AGGREGATOR_PASSWORD', 'LOG_AGGREGATOR_PASSWORD',
field_class=fields.CharField, field_class=fields.CharField,
allow_null=True,
label=_('Logging Aggregator Password to Authenticate With'), label=_('Logging Aggregator Password to Authenticate With'),
help_text=_('Password for Logstash or others (basic auth)'), help_text=_('Password for Logstash or others (basic auth)'),
category=_('Logging'), category=_('Logging'),
@@ -267,9 +273,15 @@ register(
register( register(
'LOG_AGGREGATOR_LOGGERS', 'LOG_AGGREGATOR_LOGGERS',
field_class=fields.StringListField, field_class=fields.StringListField,
default=['awx', 'activity_stream', 'job_events', 'packages', 'services', 'ansible'], default=['awx', 'activity_stream', 'job_events', 'system_tracking'],
label=_(''), label=_('Loggers to send data to the log aggregator from'),
help_text=_(''), help_text=_('List of loggers that will send HTTP logs to the collector, these can '
'include any or all of: \n'
'activity_stream - logs duplicate to records entered in activity stream\n'
'job_events - callback data from Ansible job events\n'
'system_tracking - data generated from scan jobs\n'
'Sending generic Tower logs must be configured through local_settings.py'
'instead of this mechanism.'),
category=_('Logging'), category=_('Logging'),
category_slug='logging', category_slug='logging',
) )