Add logtail if=$variable filtering and update log format examples
- ipng_stats_logtail now accepts an optional if=$variable parameter that suppresses log lines when the variable is empty or "0", following the same semantics as nginx's access_log if=. The condition is checked before format rendering for zero overhead on filtered requests. Filtered requests are still counted by stats. - Log format examples updated to include $scheme for http/https visibility, and renamed to ipng_stats_logtail to match production. - Robot test added for the if= filter (19 tests, 19 pass). - FR-8.5 added to design doc for the if= semantics.
This commit is contained in:
@@ -146,6 +146,15 @@ UDP logtail
|
||||
# Tab-separated format
|
||||
Should Match Regexp ${output} \\t
|
||||
|
||||
Logtail if= filter
|
||||
[Documentation] Requests to /notfound are suppressed from logtail by
|
||||
... the if=$logtail_enabled condition, but still counted.
|
||||
${output} = Docker Exec ${SERVER} cat /var/log/nginx/logtail-udp.log
|
||||
Should Not Contain ${output} /notfound
|
||||
# But /notfound IS in the regular access log (not filtered there).
|
||||
${access} = Docker Exec ${SERVER} cat /var/log/nginx/access.log
|
||||
Should Contain ${access} /notfound
|
||||
|
||||
VIP in access log
|
||||
[Documentation] $server_addr resolves to real IPs, not 0.0.0.0.
|
||||
${output} = Docker Exec ${SERVER} cat /var/log/nginx/access.log
|
||||
|
||||
@@ -19,10 +19,15 @@ http {
|
||||
access_log /var/log/nginx/access.log tagged;
|
||||
|
||||
# Global logtail — fires for ALL requests regardless of server block.
|
||||
log_format logtail '$host\t$remote_addr\t$ipng_source_tag\t$server_addr\t'
|
||||
'$request_method\t$request_uri\t$status\t$body_bytes_sent\t'
|
||||
'$request_time';
|
||||
ipng_stats_logtail logtail udp://127.0.0.1:9514 buffer=4k flush=500ms;
|
||||
# The if= condition suppresses /notfound from the logtail stream.
|
||||
map $request_uri $logtail_enabled {
|
||||
~^/notfound 0;
|
||||
default 1;
|
||||
}
|
||||
log_format ipng_stats_logtail '$host\t$remote_addr\t$request_method\t$request_uri\t'
|
||||
'$status\t$body_bytes_sent\t'
|
||||
'$ipng_source_tag\t$server_addr\t$scheme';
|
||||
ipng_stats_logtail ipng_stats_logtail udp://127.0.0.1:9514 buffer=4k flush=500ms if=$logtail_enabled;
|
||||
|
||||
server {
|
||||
# Mgmt-only listener for direct traffic (tagged "direct").
|
||||
|
||||
Reference in New Issue
Block a user