filebeat+redis+elk搭建日志分析系统
各个组件作用:
filebeat:具有日志收集功能,是下一代的Logstash收集器,但是filebeat更轻量,占用资源更少,适合客户端使用。
redis:Redis 服务器通常都是用作 NoSQL 数据库,不过 logstash 只是用来做消息队列。
logstash:主要是用来日志的搜集、分析、过滤日志的工具,支持大量的数据获取方式。一般工作方式为c/s架构,client端安装在需要收集日志的主机上,server端负责将收到的各节点日志进行过滤、修改等操作在一并发往elasticsearch上去。
elasticsearch:Elasticsearch是个开源分布式搜索引擎,提供搜集、分析、存储数据三大功能。它的特点有:分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等。
kibana:Kibana可以为 Logstash 和 ElasticSearch 提供的日志分析友好的 Web 界面,可以帮助汇总、分析和搜索重要数据日志。
https://www.elastic.co下载相应的安装包
filebeat安装配置:
vim /usr/local/ELK/filebeat-6.3.1-linux-x86_64/filebeat.yml
- type: log
# Change to true to enable this input configuration.
enabled: true
# Paths that should be crawled and fetched. Glob based paths.
paths:
- '/data/nginx-logs/*access*'
#json.keys_under_root: true
#json.overwrite_keys: true
tags: ["json_nginxaccess"]
document_type: json-nginxaccess
#fields:
# log_source: nginx
- type: log
enabled: true
paths:
- '/data/nginx-logs/*error*'
#json.keys_under_root: true
#json.overwrite_keys: true
tags: ["json_nginxerror"]
document_type: json-nginxerror