From 757e9e6bb8fb3647ecccd144c851c27bf5cc464c Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 26 Aug 2023 17:21:23 +0200 Subject: [PATCH] bundles/nginx: add option to disable anon_timing log --- bundles/nginx/files/site_template | 2 ++ bundles/nginx/items.py | 1 + bundles/nginx/metadata.py | 9 ++++++--- bundles/weechat/metadata.py | 4 ++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bundles/nginx/files/site_template b/bundles/nginx/files/site_template index bccff8c..a3271e3 100644 --- a/bundles/nginx/files/site_template +++ b/bundles/nginx/files/site_template @@ -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: diff --git a/bundles/nginx/items.py b/bundles/nginx/items.py index eb59250..4663f92 100644 --- a/bundles/nginx/items.py +++ b/bundles/nginx/items.py @@ -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, diff --git a/bundles/nginx/metadata.py b/bundles/nginx/metadata.py index ba2d18a..4d926f7 100644 --- a/bundles/nginx/metadata.py +++ b/bundles/nginx/metadata.py @@ -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}', diff --git a/bundles/weechat/metadata.py b/bundles/weechat/metadata.py index 939bc74..506b5d1 100644 --- a/bundles/weechat/metadata.py +++ b/bundles/weechat/metadata.py @@ -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',