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: % if create_access_log:
access_log /var/log/nginx/access-${vhost}.log gdpr; access_log /var/log/nginx/access-${vhost}.log gdpr;
% endif % endif
% if create_timing_log:
access_log /var/log/nginx-timing/${vhost}.log anon_timing; access_log /var/log/nginx-timing/${vhost}.log anon_timing;
% endif
# error_log is disabled globally # error_log is disabled globally
% if max_body_size: % if max_body_size:

View file

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

View file

@ -189,9 +189,12 @@ def firewall(metadata):
def telegraf_anon_timing(metadata): def telegraf_anon_timing(metadata):
result = {} result = {}
for vhost in metadata.get('nginx/vhosts', {}): for vname, vconfig in metadata.get('nginx/vhosts', {}).items():
result[f'nginx-{vhost}'] = { if not vconfig.get('timing_log', True):
'files': [f'/var/log/nginx-timing/{vhost}.log'], continue
result[f'nginx-{vname}'] = {
'files': [f'/var/log/nginx-timing/{vname}.log'],
'from_beginning': False, 'from_beginning': False,
'grok_patterns': ['%{LOGPATTERN}'], '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}', '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': { 'vhosts': {
'weechat': { 'weechat': {
'domain': relay_domain, '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': { 'locations': {
'/weechat': { '/weechat': {
'proxy_read_timeout': '12h', 'proxy_read_timeout': '12h',