收集Nginx的json格式日志(五)
一.配置nginx
[root@linux-node1 ~]# vim /etc/nginx/nginx.conf
#修改日志格式为json格式,并创建一个nginxweb的网站目录
log_format access_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",'
'"domain":"$host",'
'"xff":"$http_x_forwarded_for",'
'"referer":"$http_referer",'
'"status":"$status"}';
access_log /var/log/nginx/access.log access_json; location /nginxweb {
root html;
index index.html index.htm;
}
[root@linux-node1 ~]# mkdir /usr/share/nginx/html/nginxweb
[root@linux-node1 ~]# echo "<h1> welcome to use Nginx" > /usr/share/nginx/html/nginxweb/index.html
[root@linux-node1 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@linux-node1 ~]# systemctl start nginx
 
二、配置logstash
# vim /etc/logstash/conf.d/nginxlog.conf
input{
file {
path => "/var/log/nginx/access.log"
type => "nginx-access-log"
start_position => "beginning"
stat_interval => "2"
} } output{
elasticsearch {
hosts => ["10.0.0.22:9200"]
index => "logstash-nginx-access-log-%{+YYYY.MM.dd}"
}
}
三、Kibana展示
[[root@saltstack02 ~]# ab -n1000 -c 100 http://10.0.0.22/nginxweb/index.html #对页面压测 [root@saltstack02 conf.d]# tailf /var/log/nginx/access.log #nginx的访问日志变成了json格式
{"@timestamp":"2018-06-20T19:14:30+08:00","host":"10.0.0.22","clientip":"10.0.0.22","size":26,"responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"10.0.0.22","url":"/nginxweb/index.html","domain":"10.0.0.22","xff":"-","referer":"-","status":"200"}
{"@timestamp":"2018-06-20T19:14:30+08:00","host":"10.0.0.22","clientip":"10.0.0.22","size":26,"responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"10.0.0.22","url":"/nginxweb/index.html","domain":"10.0.0.22","xff":"-","referer":"-","status":"200"}
{"@timestamp":"2018-06-22T09:10:42+08:00","host":"10.0.0.22","clientip":"10.0.0.1","size":26,"responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"10.0.0.22","url":"/nginxweb/index.html","domain":"10.0.0.22","xff":"-","referer":"-","status":"200"}
Head插件查看:


收集Nginx的json格式日志(五)的更多相关文章
- filebeat收集nginx的json格式日志
		一.在nginx主机上安装filebeat组件 [root@zabbix_server nginx]# cd /usr/local/src/ [root@zabbix_server src]# wge ... 
- Logstash动态模板映射收集Nginx的Json格式日志
		Logstash传输给ES的数据会自动映射为5索引,5备份,字段都为text的的索引.这样基本上无法进行数据分析.所以必须将Logstash的数据按照既定的格式存储在ES中,这时候就要使用到ES模板技 ... 
- 使用filebeat解析nginx的json格式日志,并且保存原始message字段的值,输出到es中并通过grafana图形化显示
		1.nginx日志调成json样式 log_format json '{"@timestamp":"$time_iso8601",' '"server ... 
- ELK之收集Nginx、Tomcat的json格式日志
		1.安装Nginx yum -y install nginx vim /etc/nginx/nginx.conf # 修改日志格式为json格式,并创建一个nginxweb的网站目录 log_form ... 
- Nginx 高级配置-自定义json格式日志
		Nginx 高级配置-自定义json格式日志 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在大数据运维工作中,我们经常会使用flume,filebeat相关日志收集工具取收集日志 ... 
- Docker安装ELK并实现JSON格式日志分析
		ELK是什么 ELK是elastic公司提供的一套完整的日志收集以及前端展示的解决方案,是三个产品的首字母缩写,分别是ElasticSearch.Logstash和Kibana. 其中Logstash ... 
- nginx 返回json格式内容
		例子: #如果访问的ip是192.168.1.1,就直接返回json格式的内容 location / { default_type application/json; #####格式 if ( $re ... 
- Maven项目配置Logback输出JSON格式日志
		最近,项目提出需求,日志需要固定输出为JSON格式,以便后端Flink程序解析. 项目背景 项目为简单的Maven项目,日志由Filebeat采集,因此不需要配置输出至Logstash. 下面为pom ... 
- Logstash处理json格式日志文件的三种方法
		假设日志文件中的每一行记录格式为json的,如: {"Method":"JSAPI.JSTicket","Message":"JS ... 
随机推荐
- Mongodb 笔记01 MongoDB 简介、MongoDB基础知识、启动和停止MongoDB
			MongoDB 简介 1. 易于使用:没有固定的模式,根据需要添加和删除字段更加容易 2. 易于扩展:MongoDB的设计采用横向扩展.面向文档的数据模型使它能很容易的再多台服务器之间进行分割.自动处 ... 
- poj 1961 Period
			Period http://poj.org/problem?id=1961 Time Limit: 3000MS Memory Limit: 30000K Description Fo ... 
- 半小时让你成为EXCEL高手
- expect嵌套shell循环
			#!/bin/bash Detailtxt="test.txt" while read line do dest=`echo $line|awk '{print $1}'` ip= ... 
- IOC轻量级框架之Autofac
			http://www.cnblogs.com/WeiGe/p/3871451.html http://www.cnblogs.com/hkncd/archive/2012/11/21/2780041. ... 
- Mycat从入门到放弃
			https://blog.csdn.net/u013235478/article/details/53178657 
- [csp-201809-4]再卖菜 差分约束or记忆化搜索
			先更新第一个做法:差分约束 转化成最长路,求出的每一个解是满足差分方程的最小值 spfa求最短路 对于边(x->y) 有: if(dis[y] > dis[x] + a[i].d) dis ... 
- 【专题】计数问题(排列组合,容斥原理,Prufer序列)
			[容斥原理] 对于统计指定排列方案数的问题,一个方案是空间中的一个元素. 定义集合x是满足排列中第x个数的限定条件的方案集合,设排列长度为S,则一共S个集合. 容斥原理的本质是考虑[集合交 或 集合交 ... 
- C# XML序列化和反序列化
			using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ... 
- 免費域名申請.me .im .in .co .la .do .ms .kz .tk .ru .mu .pn .tt
			免費申請域名 .la .la 域名 – 原先是ICANN分配給老撾的國家頂級域名,不過後來被同時作為了美國洛杉矶市的域名後綴. 免費申請地址: http://www.idv.la http://www ... 
