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. “我”这个字的unicode码到底是25105

    “我”这个字的unicode码到底是25105 “我”这个字的unicode码到底是25105 “我”这个字的unicode码到底是25105

  2. [人物存档]【AI少女】【捏脸数据】时尚

    点击下载(城通网盘):3in1.zip 点击下载(城通网盘):存档.zip

  3. SQL Server代码的一种学习方法

    使用SQL Server Management Studio的操作过程中,界面上方都可以生成sql脚本代码. 如新建数据库时: CREATE DATABASE [db_New] ON PRIMARY ...

  4. D. Make a Permutation!(思维)

    D. Make a Permutation! time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. JavaWeb-SpringSecurity在数据库中查询登陆用户

    系列博文 项目已上传至guthub 传送门 JavaWeb-SpringSecurity初认识 传送门 JavaWeb-SpringSecurity在数据库中查询登陆用户 传送门 JavaWeb-Sp ...

  6. vue + ts Vuex篇

    Vuex对Typescript的支持,仍十分薄弱,官方库只是添加了一些.d.ts声明文件,并没有像vue 2.5这样内置支持. 第三方衍生库 vuex-typescript, vuex-ts-deco ...

  7. Runtime Error R6034 Application has attempt to load the C runtime library incorrectly

    1.问题描述 vs2015 去开发一个写入pg数据库的程序,使用libpqxx.dll,libpq.dll,这个库文件之前是用vs2008的程序中复制过来的,基于的运行时库应该是vs2008,现在开发 ...

  8. Maximum upload size exceede上传文件大小超出解决

    在这里记录三种方法, 努力提高自己的姿势水平 application.yml配置 spring: servlet: multipart: enabled: true max-file-size: 10 ...

  9. CodeForces 137A

    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description Polyca ...

  10. CI集成Smarty的实现方式

    给新伙伴的忠告:不要去想着有多复杂,看一遍绝对就会弄了! 这样集成的目的是什么? 因为我使用过CI和smarty,所以我就按自己的理解讲一下:CI框架在控制器.models方面做的很好,但在多变的视图 ...