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. SQL语句order by两个字段同时排序
  2. 做项目开发你必须得掌握的知识:设计模式
  3. HDU1421 搬寝室
  4. Python习题week1
  5. 强大的端到端语音识别框架—RNN-T
  6. 思科全球云指数:2010-2015预测报告
  7. 事半功倍系列之javascript (转载)
  8. Unity3d Asset Server启动问题
  9. 应用前瞻||强化学习求解车间调度问题的未来
  10. 乔姆斯基生成语法_乔姆斯基的转换生成语法理论
  11. Word导出PDF后,PDF没有生成Word中对应的目录
  12. 人工智能在肿瘤成像中的临床挑战和应用
  13. 创翼linux版本,创翼电信客户端for Mac-创翼客户端Mac版下载 V1.3.7-PC6苹果网
  14. 从头开始阅读PyTorch代码 -- Operators篇
  15. 数据处理第一节:选取列的基本到高级方法
  16. DYNAMIC DETECTION
  17. [干货][互联网]备战春招秋招的经验分享
  18. 都才40出头,近一个月已有至少5名优秀青年学者英年早逝!健康不容忽视
  19. I。quadratic equation 山东第八届省赛
  20. Oracle数据库 登录命令 用户管理 建表 修改字段 数据类型 约束 增删改查

热门文章

  1. PS网页教程:使用Photoshop设计网页布局
  2. 爬虫-获取百度图片壁纸保存至本地
  3. python批量下载静态页面_爬虫实战之,爬取壁纸,批量下载
  4. 荣光医院医道会比赛策略
  5. 升级OpenSSL修复高危漏洞Heartbleed
  6. 我的眼睛疼,脑袋疼,想睡觉。。。。。。 :(
  7. 计算机控制系统性能分析实验体会,实验一:计算机控制系统性能分析lrk
  8. 走近IT审计员(zt)
  9. ESP32-C3入门教程 基础篇⑪——Non-Volatile Storage (NVS) 非易失性存储参数的读写
  10. 国产数据库南大通用GBase 8s学习路径