diff --git a/awx/main/conf.py b/awx/main/conf.py index ce6b33217c52..b9fb5706bc2e 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -787,6 +787,29 @@ def _load_default_license_from_file(): category=_('Logging'), category_slug='logging', ) +register( + 'LOG_AGGREGATOR_MAX_DISK_USAGE_GB', + field_class=fields.IntegerField, + default=1, + min_value=1, + label=_('Maximum disk persistance for external log aggregation (in GB)'), + help_text=_('Amount of data to store (in gigabytes) during an outage of ' + 'the external log aggregator (defaults to 1). ' + 'Equivalent to the rsyslogd queue.maxdiskspace setting.'), + category=_('Logging'), + category_slug='logging', +) +register( + 'LOG_AGGREGATOR_MAX_DISK_USAGE_PATH', + field_class=fields.CharField, + default='/var/lib/awx', + label=_('File system location for rsyslogd disk persistence'), + help_text=_('Location to persist logs that should be retried after an outage ' + 'of the external log aggregator (defaults to /var/lib/awx). ' + 'Equivalent to the rsyslogd queue.spoolDirectory setting.'), + category=_('Logging'), + category_slug='logging', +) register( diff --git a/awx/main/utils/external_logging.py b/awx/main/utils/external_logging.py index 32b67542a867..9b2e7f9fdf0a 100644 --- a/awx/main/utils/external_logging.py +++ b/awx/main/utils/external_logging.py @@ -1,3 +1,5 @@ +import os + import urllib.parse as urlparse from django.conf import settings @@ -13,12 +15,18 @@ def construct_rsyslog_conf_template(settings=settings): port = getattr(settings, 'LOG_AGGREGATOR_PORT', '') protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', '') timeout = getattr(settings, 'LOG_AGGREGATOR_TCP_TIMEOUT', 5) + max_disk_space = getattr(settings, 'LOG_AGGREGATOR_MAX_DISK_USAGE_GB', 1) + spool_directory = getattr(settings, 'LOG_AGGREGATOR_MAX_DISK_USAGE_PATH', '/var/lib/awx').rstrip('/') + + if not os.access(spool_directory, os.W_OK): + spool_directory = '/var/lib/awx' + max_bytes = settings.MAX_EVENT_RES_DATA parts.extend([ '$WorkDirectory /var/lib/awx/rsyslog', f'$MaxMessageSize {max_bytes}', '$IncludeConfig /var/lib/awx/rsyslog/conf.d/*.conf', - 'main_queue(queue.spoolDirectory="/var/lib/awx" queue.maxdiskspace="1g" queue.type="Disk" queue.filename="awx-external-logger-backlog")', + f'main_queue(queue.spoolDirectory="{spool_directory}" queue.maxdiskspace="{max_disk_space}g" queue.type="Disk" queue.filename="awx-external-logger-backlog")', # noqa 'module(load="imuxsock" SysSock.Use="off")', 'input(type="imuxsock" Socket="' + settings.LOGGING['handlers']['external_logger']['address'] + '" unlink="on")', 'template(name="awx" type="string" string="%rawmsg-after-pri%")', diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 9fb1e7e6f65d..7280866d6d6c 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -936,6 +936,8 @@ def IS_TESTING(argv=None): LOG_AGGREGATOR_TCP_TIMEOUT = 5 LOG_AGGREGATOR_VERIFY_CERT = True LOG_AGGREGATOR_LEVEL = 'INFO' +LOG_AGGREGATOR_MAX_DISK_USAGE_GB = 1 +LOG_AGGREGATOR_MAX_DISK_USAGE_PATH = '/var/lib/awx' # The number of retry attempts for websocket session establishment # If you're encountering issues establishing websockets in clustered Tower,