从零编写日志分析系统之nginx日志配置
2017-09-05 10:28
447 查看
配置nginx日志文件
nginx原有的配置文件包含的信息比较少,可以修改nginx.conf得到更多的数据。nginx日志文件输出形式有三种形式,最常见的就是通过空格区分字段输出。还有通过自定义json形式输出,通过syslog直接输出到远端服务。
通过空格区分输出
log_format main '$remote_addr $remote_user [$time_local] "$request" $http_host ' '$status $upstream_status $body_bytes_sent "$http_referer"' '"$http_user_agent” $ssl_protocol $ssl_cipher $upstream_addr ' '$request_time $upstream_response_time';
通过自定义json输出
- log_format json '{"@timestamp":"$time_iso8601",' '"host":"$server_addr",' '"clientip":"$remote_addr",' '"size":$body_bytes_sent,' '"responsetime":$request_time,' '"upstreamtime":"$upstream_response_time",' '"upstreamhost":"$upstream_addr",' '"http_host":"$host",' '"url":"$uri",' '"xff":"$http_x_forwarded_for",' '"referer":"$http_referer",' '"agent":"$http_user_agent",' '"status":"$status"}';
发送到远端服务
- access_log syslog:server=unix:/data0/rsyslog/nginx.sock locallog;
发送到logstarsh
access_log syslog:server=192.168.0.2:5140,facility=local6,tag=ng inx_access,severity=info logstashlog;
附录:nginx日志参数说明
参考:ELK stack中文指南
相关文章推荐
- 从零编写日志分析系统之filebeat安装配置
- ELK6.2.2日志分析监控系统搭建和配置
- 从零编写日志分析系统之需求分析
- Nginx配置Awstats分析Nginx日志笔记
- ELK日志分析系统 介绍 安装配置
- 从零编写日志分析系统之linux用户创建
- Nginx 日志分析 AWStats + JAWStats 安装配置
- ELK6.2.2日志分析监控系统搭建和配置
- ELK日志收集分析系统配置
- 搭建ELK(ElasticSearch+Logstash+Kibana)日志分析系统(八) elasticsearch配置外网访问及常见错误处理
- Logstash+Redis+Elasticsearch+Kibana+Nginx搭建日志分析系统
- nginx服务器access_log日志分析及配置详解
- 搭建ELK(ElasticSearch+Logstash+Kibana)日志分析系统(十五) logstash将配置写在多个文件
- Nginx配置的rewrite编写时last与break的区别分析
- linux系统centOS6.5使用goaccess工具分析nginx网站日志
- AWStats 日志分析工具【配置分析其他服务器nginx日志】
- ELK日志分析系统搭建配置
- nginx服务器access_log日志分析及配置详解
- ELK安装配置及nginx日志分析
- 搭建ELK(ElasticSearch+Logstash+Kibana)日志分析系统(二) Logstash简介及常见配置语法