Skip to content
This repository was archived by the owner on Mar 25, 2022. It is now read-only.

Commit 3b0d895

Browse files
author
Lars Gierth
committed
nginx: log used upstream, and avoid unneccessary upstream switches
License: MIT Signed-off-by: Lars Gierth <[email protected]>
1 parent 130f132 commit 3b0d895

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

mtail/progs/nginx.mtail

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ counter http_response_size_bytes_sum by vhost, method, code, content_type
1818
/(?P<request_seconds>\d+)\.(?P<request_milliseconds>\d+) / +
1919
/"(?P<http_referer>\S+)" / +
2020
/"(?P<http_user_agent>[[:print:]]+)" / +
21-
/"(?P<content_type>[^;]+)(;.*)?"/ +
21+
/"(?P<content_type>[^;]+)(;.*)?" / +
22+
/upstream="(?P<upstream>[[:print:]]*)"/ +
2223
/$/ {
2324
http_requests_total[$vhost][tolower($request_method)][$status][$content_type]++
2425
http_request_duration_milliseconds_sum[$vhost][tolower($request_method)][$status][$content_type] += $request_seconds * 1000 + $request_milliseconds

nginx/nginx.conf

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
user nginx;
22
worker_processes 1;
3-
4-
error_log /var/log/nginx/error.log warn;
5-
pid /var/run/nginx.pid;
6-
3+
pid /var/run/nginx.pid;
74

85
events {
96
worker_connections 10240;
@@ -17,7 +14,7 @@ http {
1714

1815
log_format mtail '$server_name $remote_addr - $remote_user [$time_local] '
1916
'"$request" $status $bytes_sent $request_time '
20-
'"$http_referer" "$http_user_agent" "$sent_http_content_type"';
17+
'"$http_referer" "$http_user_agent" "$sent_http_content_type" upstream="$upstream_addr"';
2118

2219
access_log off;
2320
error_log /var/log/nginx/error.log warn;
@@ -63,6 +60,7 @@ http {
6360
text/x-cross-domain-policy;
6461
# text/html is always compressed by gzip module
6562

63+
proxy_next_upstream error;
6664
proxy_buffering off;
6765
proxy_buffer_size 4k;
6866

0 commit comments

Comments
 (0)