前言
Beats 是作为ELK技术栈前端数据收集平台的一个开源软件
Beats is the platform for building lightweight, open source data shippers for many types of operational data you want to enrich with Logstash, search and analyze in Elasticsearch, and visualize in Kibana.
Whether you’re interested in log files, infrastructure metrics, network packets, or any other type of data, Beats serves as the foundation for keeping a beat on your data
目前有官方支持的三个子产品:packetbeat、topbeat、filebeat
下面是它们之间的关系
正文
1.前期准备
下载地址
elastic.co/cn/downloads/
2.filebeat
filebeat 配置文件
testfilebeat.yml
1 2 3 4 5 6 7 8 9 10 11 12 |
filebeat: inputs: - paths: - C:\tmp\pdm-lite-project\*.log fields: service: project_name output: #elasticsearch: # hosts: [ "localhost:9200" ] logstash: hosts: [ "localhost:5044" ] |
启动命令
多个输入
filebeat: inputs: - paths: - /usr/local/elk/redislog/*.log # 相当于logstash中的type fields: service: redis - paths: - /usr/local/elk/log/*.log fields: service: ecps output: #elasticsearch: # hosts: [ "localhost:9200" ] logstash: hosts: [ "172.30.1.45:5044" ] |
3.logstash
logstash 配置文件
logstash_filebeat.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
input { beats { port => 5044 } } filter { multiline { pattern => "^\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2}" negate => true what => "previous" } } output { if [fields][service] == "project_name" { elasticsearch { hosts => [ "localhost:9200" ] index => "project_name-%{+YYYY.MM.dd}" } } stdout { codec => rubydebug } } |
启动命令
- bin目录下启动logstash:logstash -f logstash_filebeat.conf
4.Elasticsearch
5.Kibana
config/kibana.yml
6.grafana(进阶)
可以将数据进行实时监测,并图表展示。
常见问题
logstash-启动报错-安装multiline以及multiline使用方法
参考文章
Filebeat安装及使用
logstash匹配多行日志
Logstash+Filebeats+Elasticsearch实现数据抽取https://blog.csdn.net/fenglixiong123/article/details/108081235