1.本次采用的一台主机,将所有的软件安装一台上进行测试工作。

2.安装部署:https://blog.51cto.com/hwg1227/2299995

3.简单调试

输出rubydebug
input{
file {
path => "/usr/local/log_test/*/*/*.log"
start_position => "beginning"
}
}

output {
elasticsearch {
hosts => ["10.0.0.92:9200"]
index => "myre-%{+YYY.MM.dd}"
}
stdout {codec => rubydebug}
}

--------------------- 

原文:https://blog.csdn.net/yelllowcong/article/details/80847425 

4.nginx日志格式

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

5.filter的定义 参考:https://www.cnblogs.com/52fhy/p/10160795.html

filter {
grok {
match => { "message" => "%{IPORHOST:remote_ip} - %{DATA:user_name} \[%{HTTPDATE:time}\] \"%{WORD:method} %{DATA:url} HTTP/%{NUMBER:http_version}\" %{NUMBER:response_code} %{NUMBER:body_sent:bytes} \"%{DATA:referrer}\" \"%{DATA:agent}\" \"%{DATA:x_forwarded_for}\" %{NUMBER:request_time}" }
# remove_field => "message"
}
}

########################################################

1.目标定义好nginx的日志格式为json格式。分割成多份。demo:统计11:00 - 11:50的404status状态的访问

2.nginx的日志格式

参考:https://www.linuxidc.com/Linux/2017-12/149811.htm

[root@rbtnode1 nginx]# cat /usr/local/nginx/conf/nginx.conf|egrep -v '#|^$'
。。。
http {
include mime.types;
default_type application/octet-stream;
log_format json '{ "@timestamp": "$time_iso8601", '
'"time": "$time_iso8601", '
'"remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
'"body_bytes_sent": "$body_bytes_sent", '
'"request_time": "$request_time", '
'"status": "$status", '
'"host": "$host", '
'"request": "$request", '
'"request_method": "$request_method", '
'"uri": "$uri", '
'"http_referrer": "$http_referer", '
'"body_bytes_sent":"$body_bytes_sent", '
'"http_x_forwarded_for": "$http_x_forwarded_for", '
'"http_user_agent": "$http_user_agent" '
'}';
access_log /var/log/nginx/access.log json;
sendfile on;
keepalive_timeout 65;

。。。
}

3.logstash的配置文件,连接es

[root@VM_0_92_centos bin]# cat  ../config/nginxdemojson.conf
input{
file {
path => "/var/log/nginx/access.log"
codec => "json"
}
}
filter{
} output {
elasticsearch {
hosts => ["10.0.0.92:9200"]
index => "demo-%{+YYY.MM.dd}"
}
stdout {codec => rubydebug}
}

参考:https://www.cnblogs.com/liaojiafa/p/6158245.html

---------------------------------------------------------------------------------------------------------------------

3.修改配置文件

vim config/elasticsearch.yml
#修改为自己的ip
network.host: x.x.x.x
#把这个注释先放开
cluster.initial_master_nodes: ["node-1", "node-2"]

4.修改limit文件

vim /etc/security/limits.conf
* soft nofile
* hard nofile
* soft nproc
* hard nproc vi /etc/sysctl.conf
vm.max_map_count=
sysctl -p

elk 入门 - 分析nginx日志 + json格式 + 有调试的意识 + elk7.2.0的更多相关文章

  1. elk实战分析nginx日志文档

    elk实战分析nginx日志文档 架构: kibana <--- es-cluster <--- logstash <--- filebeat 环境准备:192.168.3.1 no ...

  2. ElastAlert监控日志告警Web攻击行为---tomcat和nginx日志json格式

    一.ELK安装 1.2 elk配置 logstash自定义配置文件,取名为filebeat_log.conf : input { beats { port => 5044 client_inac ...

  3. elk平台分析nginx日志的基本搭建

    一.elk套件介绍 ELK 由 ElasticSearch . Logstash 和 Kiabana 三个开源工具组成.官方网站: https://www.elastic.co/products El ...

  4. ELK学习实验014:Nginx日志JSON格式收集

    1 Kibana的显示配置 https://demo.elastic.co/app/kibana#/dashboard/welcome_dashboard 环境先处理干净 安装nginx和httpd- ...

  5. elk系列3之通过json格式采集Nginx日志

    preface 公司采用的LNMP平台,跑着挺多nginx,所以可以利用elk好好分析nginx的日志.下面就聊聊它吧. 下面的所有操作都在linux-node2上操作 安装Nginx nginx是开 ...

  6. elk系列3之通过json格式采集Nginx日志【转】

    转自 elk系列3之通过json格式采集Nginx日志 - 温柔易淡 - 博客园http://www.cnblogs.com/liaojiafa/p/6158245.html preface 公司采用 ...

  7. 使用Docker快速部署ELK分析Nginx日志实践

    原文:使用Docker快速部署ELK分析Nginx日志实践 一.背景 笔者所在项目组的项目由多个子项目所组成,每一个子项目都存在一定的日志,有时候想排查一些问题,需要到各个地方去查看,极为不方便,此前 ...

  8. ELK+redis搭建nginx日志分析平台

    ELK+redis搭建nginx日志分析平台发表于 2015-08-19   |   分类于 Linux/Unix   |  ELK简介ELKStack即Elasticsearch + Logstas ...

  9. elk收集分析nginx access日志

    elk收集分析nginx access日志 首先elk的搭建按照这篇文章使用elk+redis搭建nginx日志分析平台说的,使用redis的push和pop做队列,然后有个logstash_inde ...

随机推荐

  1. mysql 查看删除触发器等操作

    mysql 查看删除触发器等操作 平时很少操作触发器,源于昨晚的一次故障,使用pt-online-change-schema修改大表过程中出现异常,再次执行时,提示已经存在触发器,导致失败. 这里推荐 ...

  2. [React] Always useMemo your context value

    Have a similar post about Reac.memo. This blog is the take away from this post. To understand why to ...

  3. input 唤起键盘后遮住页面元素

    var windheight = $(window).height(); /*未唤起键盘时当前窗口高度*/ $(window).resize(function(){ var docheight = $ ...

  4. 51 Nod 1072 威佐夫游戏

    https://baike.baidu.com/item/%E5%A8%81%E4%BD%90%E5%A4%AB%E5%8D%9A%E5%BC%88/19858256?fr=aladdin&f ...

  5. K8S中Service

    Service 的概念Kubernetes  Service  定义了这样一种抽象:一个  Pod  的逻辑分组,一种可以访问它们的策略 —— 通常称为微服务. 这一组  Pod  能够被  Serv ...

  6. Mysql主从同步 异常Slave_SQL_Running: No

    在刚搭建好的mysql主从节点上对从节点进行操作,导致同步异常:报错如下: 从节点执行: mysql> show slave status\G;************************* ...

  7. MySQL_(Java)使用JDBC向数据库中删除(delete)数据

    MySQL_(Java)使用JDBC向数据库发起查询请求 传送门 MySQL_(Java)使用JDBC向数据库中插入(insert)数据 传送门 MySQL_(Java)使用JDBC向数据库中删除(d ...

  8. 第六天-css基础(css定位)

    css定位   方位名称:  left  right  top  bottom   position:absolute 绝对定位(脱离标准流 div{ width:100px; height:100p ...

  9. shell 之 用linux定时任务crontab和watchdog.sh脚本做软件看门狗

    1.简介 看门狗的作用是定期检测服务正常运行,如果发现服务不在了,会重新拉起服务:linux中可以利用系统的定时任务功能crontab定期的去执行watchdog.sh脚本,而watchdog.sh脚 ...

  10. 三、Reids(高性能)key-value服务器知识整合

    一.Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. 知识链接:https://www.runoob.com/redis/redis-backup.html ht ...