t-cyrill / munin-nginx_request_time

Munin plugin for nginx request time
MIT License
8 stars 1 forks source link

Change log format to let Logwatch work with no modification #4

Open taro-k opened 8 years ago

taro-k commented 8 years ago

If we change Nginx log format by following the instruction, httpd section of Logwatch doesn't work. To solve this problem, we can change setting of Logwatch, however, I think it's much better that no such change/modification is required.

Do you have a specific reason for the suggested format?

If no, I'd recommend that the log format is combined+request_time:

'$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '$request_time';

, which is OK with Logwatch at least my server. If you can accept this, I can make PR of the corresponding code.

t-cyrill commented 8 years ago

munin-nginx_request_time don't take care of logwatch. Generally, logwatch watch nginx's access_log that is placed /var/log/nginx/access.log.

If you don't want to track access.log, you can change log name to add nginx access_log directive. And modify your logwatch configration to exclude tsv access log (request_time_stats.log).

nginx.conf

log_format main '$remote_addr - $remote_user [$time_local] '
                '"$request" $status $body_bytes_sent '
                '"$http_referer" "$http_user_agent" '
                '$request_time';
log_format request_time_stats   '$time_local\t'
                                '$status\t'
                                '$request_time\t'
                                '$remote_addr\t'
                                '$upstream_addr\t'
                                '$upstream_response_time\t'
                                '$request';

access_log  /var/log/nginx/access.log  main;
access_log  /var/log/nginx/request_time_stats.log request_time_stats;

logwatch/conf/logfiles/nginx.conf

LogFile = nginx/access.log

Thank you.

taro-k commented 8 years ago

https://github.com/taro-k/munin-nginx_request_time/commit/803eb1beda25ec2e9c52155094f7dcd3a43d2169

If you modify the code like this commit, we don't need such duplicate log as you wrote. At the same time, Logwatch works correctly.