ELK企业应用-elk监控nginx(一)nginx格式配置
1、概述
Nignx日志主要有access和error两种日志,access中记录客户访问的所有记录,可根据需要并按照一定的格式配置不同参数以获取不同要的信息,以便于分析和统计。
nginx日志格式配置
建议配置如下:
log_format main '$remote_addr - $remote_user [$time_local] $http_host $request_method "$uri" "$query_string" '
'$status $body_bytes_sent "$http_referer" $upstream_status $upstream_addr $request_time $upstream_response_time '
'"$http_user_agent" "$http_x_forwarded_for"' ;
2、测试环境搭建
为了快速,全yum安装,配置文件全部默认
yum install nginx php php-fpm php-web -y
3、配置
3.1.配置主文件
vim /etc/nginx/nginx.conf
###########################################3
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
############定义日志格式 log_format
log_format main '$remote_addr - $remote_user [$time_local] $http_host $request_method "$uri" "$query_string" '
'$status $body_bytes_sent "$http_referer" $upstream_status $upstream_addr $request_time $upstream_response_time '
'"$http_user_agent" "$http_x_forwarded_f