mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
Ensure log messages have valid json
- Fix messages getting contatenated at 8k - Fix rsyslog cutting off the opening brace of log messages - Make valid default conf and emit logs based on prescence of .sock and settings
This commit is contained in:
@@ -8,7 +8,6 @@ from awx.main.utils.reload import supervisor_service_command
|
|||||||
def construct_rsyslog_conf_template(settings=settings):
|
def construct_rsyslog_conf_template(settings=settings):
|
||||||
tmpl = ''
|
tmpl = ''
|
||||||
parts = []
|
parts = []
|
||||||
if settings.LOG_AGGREGATOR_ENABLED:
|
|
||||||
host = getattr(settings, 'LOG_AGGREGATOR_HOST', '')
|
host = getattr(settings, 'LOG_AGGREGATOR_HOST', '')
|
||||||
port = getattr(settings, 'LOG_AGGREGATOR_PORT', '')
|
port = getattr(settings, 'LOG_AGGREGATOR_PORT', '')
|
||||||
protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', '')
|
protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', '')
|
||||||
@@ -26,11 +25,12 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
port = parsed.port
|
port = parsed.port
|
||||||
except ValueError:
|
except ValueError:
|
||||||
port = settings.LOG_AGGREGATOR_PORT
|
port = settings.LOG_AGGREGATOR_PORT
|
||||||
|
|
||||||
max_bytes = settings.MAX_EVENT_RES_DATA
|
max_bytes = settings.MAX_EVENT_RES_DATA
|
||||||
parts.extend([
|
parts.extend([
|
||||||
'$WorkDirectory /var/lib/awx/rsyslog',
|
'$WorkDirectory /var/lib/awx/rsyslog',
|
||||||
'$IncludeConfig /etc/rsyslog.d/*.conf',
|
f'$MaxMessageSize {max_bytes}',
|
||||||
f'$MaxMessageSize {max_bytes}b',
|
'$IncludeConfig /var/lib/awx/rsyslog/conf.d/*.conf',
|
||||||
'$ModLoad imuxsock',
|
'$ModLoad imuxsock',
|
||||||
'input(type="imuxsock" Socket="' + settings.LOGGING['handlers']['external_logger']['address'] + '" unlink="on")',
|
'input(type="imuxsock" Socket="' + settings.LOGGING['handlers']['external_logger']['address'] + '" unlink="on")',
|
||||||
'template(name="awx" type="string" string="%msg%")',
|
'template(name="awx" type="string" string="%msg%")',
|
||||||
@@ -63,10 +63,11 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
params.append(f'pwd="{password}"')
|
params.append(f'pwd="{password}"')
|
||||||
params = ' '.join(params)
|
params = ' '.join(params)
|
||||||
parts.extend(['module(load="omhttp")', f'action({params})'])
|
parts.extend(['module(load="omhttp")', f'action({params})'])
|
||||||
else:
|
elif protocol and host and port:
|
||||||
parts.append(
|
parts.append(
|
||||||
f'action(type="omfwd" target="{host}" port="{port}" protocol="{protocol}" action.resumeRetryCount="-1" template="awx")' # noqa
|
f'action(type="omfwd" target="{host}" port="{port}" protocol="{protocol}" action.resumeRetryCount="-1" template="awx")' # noqa
|
||||||
)
|
)
|
||||||
|
# parts.append('$IncludeConfig /var/lib/awx/rsyslog/*.conf')
|
||||||
tmpl = '\n'.join(parts)
|
tmpl = '\n'.join(parts)
|
||||||
return tmpl
|
return tmpl
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class RSysLogHandler(logging.handlers.SysLogHandler):
|
|||||||
append_nul = False
|
append_nul = False
|
||||||
|
|
||||||
def emit(self, msg):
|
def emit(self, msg):
|
||||||
|
if not settings.LOG_AGGREGATOR_ENABLED:
|
||||||
|
return
|
||||||
if not os.path.exists(settings.LOGGING['handlers']['external_logger']['address']):
|
if not os.path.exists(settings.LOGGING['handlers']['external_logger']['address']):
|
||||||
return
|
return
|
||||||
return super(RSysLogHandler, self).emit(msg)
|
return super(RSysLogHandler, self).emit(msg)
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
$WorkDirectory /var/lib/awx/rsyslog
|
$WorkDirectory /var/lib/awx/rsyslog
|
||||||
|
$MaxMessageSize 700000
|
||||||
|
$IncludeConfig /var/lib/awx/rsyslog/conf.d/*.conf
|
||||||
|
$ModLoad imuxsock
|
||||||
|
input(type="imuxsock" Socket="/var/run/rsyslog/rsyslog.sock" unlink="on")
|
||||||
|
template(name="awx" type="string" string="%msg%")
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ ADD rsyslog.repo /etc/yum.repos.d/
|
|||||||
RUN yum install -y rsyslog-omhttp
|
RUN yum install -y rsyslog-omhttp
|
||||||
|
|
||||||
# Pre-create things that we need to write to
|
# Pre-create things that we need to write to
|
||||||
RUN for dir in /home/awx /var/run/supervisor /var/lib/awx /var/lib/awx/rsyslog /var/run/rsyslog /var/log/tower /var/log/nginx /var/lib/nginx; \
|
RUN for dir in /home/awx /var/run/supervisor /var/lib/awx /var/lib/awx/rsyslog /var/lib/awx/rsyslog/conf.d /var/run/rsyslog /var/log/tower /var/log/nginx /var/lib/nginx; \
|
||||||
do mkdir -p $dir; chmod -R g+rwx $dir; chgrp -R root $dir; done && \
|
do mkdir -p $dir; chmod -R g+rwx $dir; chgrp -R root $dir; done && \
|
||||||
\
|
\
|
||||||
for file in /etc/passwd /var/run/nginx.pid; \
|
for file in /etc/passwd /var/run/nginx.pid; \
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ ADD tools/docker-compose/entrypoint.sh /
|
|||||||
ADD tools/scripts/awx-python /usr/bin/awx-python
|
ADD tools/scripts/awx-python /usr/bin/awx-python
|
||||||
|
|
||||||
# Pre-create things that we need to write to
|
# Pre-create things that we need to write to
|
||||||
RUN for dir in /var/lib/awx /var/lib/awx/rsyslog /var/run/rsyslog /var/log/tower/ /var/lib/awx/projects /.ansible /var/log/nginx /var/lib/nginx /.local; \
|
RUN for dir in /var/lib/awx /var/lib/awx/rsyslog /var/lib/awx/rsyslog/conf.d /var/run/rsyslog /var/log/tower/ /var/lib/awx/projects /.ansible /var/log/nginx /var/lib/nginx /.local; \
|
||||||
do mkdir -p $dir; chmod -R g+rwx $dir; chgrp -R root $dir; done && \
|
do mkdir -p $dir; chmod -R g+rwx $dir; chgrp -R root $dir; done && \
|
||||||
\
|
\
|
||||||
for file in /etc/passwd /etc/supervisord.conf /venv/awx/lib/python3.6/site-packages/awx.egg-link /var/run/nginx.pid; \
|
for file in /etc/passwd /etc/supervisord.conf /venv/awx/lib/python3.6/site-packages/awx.egg-link /var/run/nginx.pid; \
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
$WorkDirectory /var/lib/awx/rsyslog
|
$WorkDirectory /var/lib/awx/rsyslog
|
||||||
|
$MaxMessageSize 700000
|
||||||
|
$IncludeConfig /var/lib/awx/rsyslog/conf.d/*.conf
|
||||||
|
$ModLoad imuxsock
|
||||||
|
input(type="imuxsock" Socket="/var/run/rsyslog/rsyslog.sock" unlink="on")
|
||||||
|
template(name="awx" type="string" string="%msg%")
|
||||||
|
|||||||
Reference in New Issue
Block a user