bundles/nginx: add option to disable anon_timing log

This commit is contained in:
Franzi 2023-08-26 17:21:23 +02:00
parent c6bb00c124
commit 757e9e6bb8
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 13 additions and 3 deletions

View file

@ -57,7 +57,9 @@ server {
% if create_access_log:
access_log /var/log/nginx/access-${vhost}.log gdpr;
% endif
% if create_timing_log:
access_log /var/log/nginx-timing/${vhost}.log anon_timing;
% endif
# error_log is disabled globally
% if max_body_size:

View file

@ -126,6 +126,7 @@ for vhost, config in node.metadata.get('nginx/vhosts', {}).items():
'content_type': 'mako',
'context': {
'create_access_log': config.get('access_log', node.metadata.get('nginx/access_log', False)),
'create_timing_log': config.get('timing_log', True),
'php_version': node.metadata.get('php/version', ''),
'security_txt': security_txt_enabled,
'vhost': vhost,

View file

@ -189,9 +189,12 @@ def firewall(metadata):
def telegraf_anon_timing(metadata):
result = {}
for vhost in metadata.get('nginx/vhosts', {}):
result[f'nginx-{vhost}'] = {
'files': [f'/var/log/nginx-timing/{vhost}.log'],
for vname, vconfig in metadata.get('nginx/vhosts', {}).items():
if not vconfig.get('timing_log', True):
continue
result[f'nginx-{vname}'] = {
'files': [f'/var/log/nginx-timing/{vname}.log'],
'from_beginning': False,
'grok_patterns': ['%{LOGPATTERN}'],
'grok_custom_patterns': 'LOGPATTERN \[%{HTTPDATE:ts:ts-httpd}\] %{NUMBER:request_time:float} (?:%{NUMBER:upstream_response_time:float}|-) "%{WORD:verb:tag} %{NOTSPACE:request} HTTP/%{NUMBER:http_version:float}" %{NUMBER:resp_code:tag}',

View file

@ -85,6 +85,10 @@ def relay_vhost(metadata):
'vhosts': {
'weechat': {
'domain': relay_domain,
# This only does websockets connections, which stay
# open for a very long time. This only generates
# useless metrics.
'timing_log': False,
'locations': {
'/weechat': {
'proxy_read_timeout': '12h',