ELK是什么?

轻量级日志统计分析组件,包含elasticsearch、filebeat、kibana

ELK环境准备

Elasticsearch 下载地址
https://www.elastic.co/downloads/past-releases/elasticsearch-6-4-2
Elasticsearch 参考文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
Filebeat 下载地址
https://www.elastic.co/downloads/past-releases/filebeat-6-4-2
Filebeat 参考文档
https://www.elastic.co/guide/en/beats/filebeat/6.4/index.html
Kibana 下载地址
https://www.elastic.co/downloads/past-releases/kibana-6-4-2
Kibana 参考文档
https://www.elastic.co/guide/en/kibana/6.4/index.html

ELK安装

下载elasticsearch-6.4.2.tar.gz
解压tar –zvxf elasticsearch-6.4.2.tar.gz
下载filebeat-6.4.2-linux-x86_64.tar.gz
解压 tar –zvxf filebeat-6.4.2-linux-x86_64.tar.gz
下载kibana-6.4.2-linux-x86_64.tar.gz
解压 tar –zvxf kibana-6.4.2-linux-x86_64.tar.gz

什么是Filebeat


如官网图片所示,Filebeat是一个轻量级的日志收集、过滤的中间件。可以向elasticsearch、logstash等推送数据。

Filebeat配置

  • Input配置
filebeat.inputs:
# 文档类型
- type: log
# 是否开启 true or falseenabled: true
# 日志路径paths:- /var/log/*.log#- c:\programdata\elasticsearch\logs\*
  • 设置Kibana
setup.kibana:host: "kibanahost:5601"
  • 设置output
output.elasticsearch:# es服务器配置hosts: ["Elasticsearchhost:9200"]# 指定索引文件名称
index: "filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"
  • Filebeat Nginx Module

Filebeat默认已经支持很多Module,通过官网可知如下

参考文档:https://www.elastic.co/guide/en/beats/filebeat/6.4/filebeat-module-nginx.html

Nginx moduleedit The nginx module parses access and error logs created
by the Nginx HTTP server.

When you run the module, it performs a few tasks under the hood:

Sets the default paths to the log files (but don’t worry, you can
override the defaults) Makes sure each multiline log event gets sent
as a single event Uses ingest node to parse and process the log lines,
shaping the data into a structure suitable for visualizing in Kibana
Deploys dashboards for visualizing the log data Compatibilityedit This
module requires the ingest-user-agent and ingest-geoip Elasticsearch
plugins.

The Nginx module was tested with logs from version 1.10.

On Windows, the module was tested with Nginx installed from the
Chocolatey repository.

官网已经明确说明,我们需要安装ingest-user-agent和ingest-geoip elasticsearch插件
这里说明一下,是要在elasticsearch下安装

安装ingest-user-agent
参考文档
https://www.elastic.co/guide/en/elasticsearch/plugins/6.4/ingest-user-agent.html
下载离线包
https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-user-agent/ingest-user-agent-6.4.2.zip.
这里我们选择离线安装
https://www.elastic.co/guide/en/elasticsearch/plugins/6.4/plugin-management-custom-url.html

下载完成后通过以下命令安装插件

sudo bin/elasticsearch-plugin install file:///path/to/plugin.zip

file:///path/to/plugin.zip 为离线插件所在路径

安装ingest-geoip

参考文档

https://www.elastic.co/guide/en/elasticsearch/plugins/6.4/ingest-geoip.html
下载离线包
https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-geoip/ingest-geoip-6.4.2.zip.
这里我们选择离线安装
https://www.elastic.co/guide/en/elasticsearch/plugins/6.4/plugin-management-custom-url.html

下载完成后通过以下命令安装插件

sudo bin/elasticsearch-plugin install file:///path/to/plugin.zip

file:///path/to/plugin.zip 为离线插件所在路径

  • 开启nginx module
./filebeat modules enable nginx

通过以下命令查看是否开启成功

./filebeat modules list

  • 配置nginx module
    进入/home/elk/filebeat-6.4.2-linux-x86_64/modules.d 路径下
vi nginx.yml


这里配置自己的access.log和error.log日志路径即可,这里是作者环境下的nginx日志路径。

启动Elasticsearch

运行

./bin/elasticsearch -d

【需要创建非root账号运行】

chown -R elasticesearch:elasticesearch elasticsearch-6.4.2

这个时候可能发现除去本机以外的机器都无法访问,即使放开了9200端口也不行。解决方案如下:
https://www.jianshu.com/p/211982465c3b

启动Kibana

配置Kibana

设置当前IP

server.host: "Kibana Host"

后台运行

./bin/kibana &

启动filebeat

nohup ./filebeat -e -c filebeat.yml > filebeat.log &

启动 dashboard

./filebeat setup --dashboards

访问Kibana

一般是localhost:5601

Nginx Dashboard

找到Nginx模块

这里说明一下,如果部署和配置过程中有试错的情况
注意
• 启动了之后 filebeat.yml中 input 不需要改变
• 之前有数据模板不对 需要清空,否则无法使用

Ok 到了这里Nginx模块我们已经搭建完成。

ELK(Elasticsearch+Filebeat+Kibana) 轻量级采集分析Nginx日志相关推荐

  1. 使用ELK(Elasticsearch + Logstash + Kibana) 搭建日志集中分析平台实践--转载

    原文地址:https://wsgzao.github.io/post/elk/ 另外可以参考:https://www.digitalocean.com/community/tutorials/how- ...

  2. CentOS 7.2下ELK分析Nginx日志生产实战(高清多图)

    注:本文系原创投稿 本文以api.mingongge.com.cn域名为测试对象进行统计,日志为crm.mingongge.com.cn和risk.mingongge.com.cn请求之和(此二者域名 ...

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

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

  4. 如何快速采集分析平台日志,并进行展示监控?

    来自:DBAplus社群 作者介绍 小火牛,项目管理高级工程师,具有多年大数据平台运维管理及开发优化经验.管理过多个上千节点集群,擅长对外多租户平台的维护开发.信科院大数据性能测试.功能测试主力,大厂 ...

  5. 使用GoAccess分析Nginx日志

    下载 GoAccess 的源代码.编译和安装: http://www.goaccess.io/download # wget http://tar.goaccess.io/goaccess-0.9.6 ...

  6. python 正则分析nginx日志

    有个需求要分析nginx日志,也懒得去研究logstach之类的开源工具,干脆直接写一个脚本,自己根据需求来实现: 先看日志格式:我们跟别人的不太一样,所以没办法了: 12.195.166.35 [1 ...

  7. python分析nginx日志

    利用python脚本分析nginx日志内容,默认统计ip.访问url.状态,可以通过修改脚本统计分析其他字段. 一.脚本运行方式 python count_log.py -f med.xxxx.com ...

  8. awk分析nginx日志里面的接口响应时间

    2019独角兽企业重金招聘Python工程师标准>>> 最近,有客户反应客户端卡,老板集合技术人员开会讨论,找出慢的原因,由此产生了分析nginx响应时间,由于线上环境nginx日志 ...

  9. python分析nginx日志_利用python分析nginx日志

    最近在学习python,写了个脚本分析nginx日志,练练手.写得比较粗糙,但基本功能可以实现. 脚本功能:查找出当天访问次数前十位的IP,并获取该IP来源,并将分析结果发送邮件到指定邮箱. 实现前两 ...

最新文章

  1. 大盘点|6D姿态估计算法汇总(下)
  2. iOS 11 UIScrollView的新特性(automaticallyAdjustsScrollViewInsets 不起作用了)
  3. Linux gdb 破解软件密码
  4. boost::signals2模块实现显示插槽通过接口传递的示例程序
  5. OpenCV cv :: UMat与DirectX11曲面的互操作性的实例(附完整代码)
  6. 媒体声音 | 憋了这么久,阿里云数据库再放大招
  7. 使用 C# (.NET Core) 实现模板方法模式 (Template Method Pattern)
  8. 基于2440的Linux开发原理,基于S3C2440和Linux的嵌入式网络驱动程序开发
  9. 学习设计模式 - 六大基本原则之开闭原则
  10. NASM汇编语言与计算机系统02-实模式-显存原理
  11. 【免费毕设】成绩查询系统(系统+论文+答辩PPT)
  12. Skyline开发1-环境搭建
  13. 计算机组成原理-复习题2
  14. Windows下的hiberfil.sys文件及其作用
  15. DM368串口通信调试
  16. file-saver 实现文件下载
  17. 熵权法STATA程序(第二版修正)
  18. Python爬虫 selenium自动化 利用搜狗搜索爬取微信公众号文章信息
  19. ETL和ELT的区别
  20. 教育行业分享-基础篇

热门文章

  1. PhotoShop 入门操作
  2. airpods2怎么查正品 ios11系统_深圳个人信用报告查询系统入口:手机要怎么查
  3. NVIDIA下一代Hopper架构曝光,采用5nm工艺 晶体管超1400亿
  4. XP盗版的来龙去脉及微软承认的完美盗版方式
  5. [英语语法]词法之数词
  6. 安装程序找不到office.zh-cn/msvcr80.dll
  7. 中国南方人才市场测评中心测评问卷
  8. 录音音质差听不清?普林斯顿提出新算法HiFi-GAN或许可以帮上忙
  9. 安防监控实现之从网页上控制A9的LED灯
  10. 视频教程-【平面设计】设计入门必看-海报设计视频教程-UI