make nginx output log in json format
This commit is contained in:
parent
8fbb18a9a2
commit
322934c19e
1 changed files with 23 additions and 5 deletions
|
@ -23,12 +23,30 @@ in
|
||||||
config = {
|
config = {
|
||||||
services.nginx.logError = lib.mkIf cfg.debugLog "stderr warn";
|
services.nginx.logError = lib.mkIf cfg.debugLog "stderr warn";
|
||||||
services.nginx.appendHttpConfig = lib.mkIf cfg.accessLog ''
|
services.nginx.appendHttpConfig = lib.mkIf cfg.accessLog ''
|
||||||
log_format postdata '$remote_addr - $remote_user [$time_local] '
|
log_format apm
|
||||||
'"$request" <$server_name> $status $body_bytes_sent '
|
'{'
|
||||||
'"$http_referer" "$http_user_agent" "$gzip_ratio" '
|
'"remote_addr":"$remote_addr",'
|
||||||
'post:"$request_body"';
|
'"remote_user":"$remote_user",'
|
||||||
|
'"time_local":"$time_local",'
|
||||||
|
'"request":"$request",'
|
||||||
|
'"request_length":"$request_length",'
|
||||||
|
'"server_name":"$server_name",'
|
||||||
|
'"status":"$status",'
|
||||||
|
'"bytes_sent":"$bytes_sent",'
|
||||||
|
'"body_bytes_sent":"$body_bytes_sent",'
|
||||||
|
'"referrer":"$http_referrer",'
|
||||||
|
'"user_agent":"$http_user_agent",'
|
||||||
|
'"gzip_ration":"$gzip_ratio",'
|
||||||
|
'"post":"$request_body",'
|
||||||
|
'"upstream_addr":"$upstream_addr",'
|
||||||
|
'"upstream_status":"$upstream_status",'
|
||||||
|
'"request_time":"$request_time",'
|
||||||
|
'"upstream_response_time":"$upstream_response_time",'
|
||||||
|
'"upstream_connect_time":"$upstream_connect_time",'
|
||||||
|
'"upstream_header_time":"$upstream_header_time"'
|
||||||
|
'}';
|
||||||
|
|
||||||
access_log syslog:server=unix:/dev/log postdata;
|
access_log syslog:server=unix:/dev/log apm;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue