如何配置Filebeat集成Elasticsearch集群?
- By : Will
- Category : Elastic Stack
1 前言
一个问题,一篇文章,一出故事。
由于Filebeat支持直接与Elasticsearch集群连接而收集日志,因此本章整理此实现步骤。
2 最佳实践
2.1 环境信息
2.1.1 主机信息
Host Name = elasticsearch[01-03].cmdschool.org
IP Address = 10.168.0.[100 – 102] OS = Oracle Linux 9.x x86_64
Elasticsearch Version = 8.11.3
另外,如果你需要部署Elasticsearch集群环境,请参阅以下文档,
Host Name = kibana.cmdschool.org
OS = Oracle Linux 9.x x86_64
IP Address = 10.168.0.99
另外,如果你需要部署Ekibana集群环境,请参阅以下文档,
Host Name = filebeat.cmdschool.org
OS = Oracle Linux 9.x x86_64
IP Address = any
另外,如果你需要部署Filebeat环境,请参阅以下文档,
2.2.2 配置名称解析
In All,
vim /etc/hosts
加入如下配置,
10.168.0.100 elasticsearch01 elasticsearch01.cmdschool.org 10.168.0.101 elasticsearch02 elasticsearch02.cmdschool.org 10.168.0.102 elasticsearch03 elasticsearch03.cmdschool.org 10.168.0.99 kibana kibana.cmdschool.org
注:以上配置仅用于测试,正式环境请使用DNS代替
2.3 配置Filebeat
2.3.1 修改配置文件
cp /etc/filebeat/filebeat.yml /etc/filebeat/filebeat.yml.default vim /etc/filebeat/filebeat.yml
配置修改如下,
filebeat.inputs: - type: filestream id: filebeat.cmdschool.org enabled: true paths: - /var/log/maillog filebeat.config.modules: path: ${path.config}/modules.d/*.yml reload.enabled: false setup.template.settings: index.number_of_shards: 3 setup.kibana: host: "kibana.cmdschool.org:5601" output.elasticsearch: hosts: ["http://elasticsearch01:9200", "http://elasticsearch02:9200", "http://elasticsearch03:9200"] output.elasticsearch.index: "filebeat-%{[agent.version]}-%{+YYYY.MM.dd}" setup.template.name: "filebeat-%{[agent.version]}-%{+YYYY.MM.dd}" setup.template.pattern: "filebeat-%{[agent.version]}-%{+YYYY.MM.dd}" setup.dashboards.index: "filebeat-*" processors: - add_host_metadata: ~
然后,你可以运行以下命令测试配置,
filebeat test config
然后,你可以运行以下命令测试Filebeat与Elasticsearch之间的配置,
filebeat test output
2.3.2 加载Kibana仪表板
filebeat setup
然后,你可以使用如下命令查看设置的日志,
filebeat -e
2.3.3 重启服务使配置生效
systemctl restart filebeat.service
2.4 使用Kibana查询日志
http://kibana.cmdschool.org:5601
单击【菜单】->【Analytics】->【Discover】->【filebeat-*】即可查询到收集到的日志,详细请参阅下图,
参阅文档
================
软件的介绍
——————
https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-overview.html
Filebeat工作原理
——————
https://www.elastic.co/guide/en/beats/filebeat/current/how-filebeat-works.html
Filebeat安装
—————–
https://www.elastic.co/guide/en/beats/filebeat/current/setup-repositories.html
Filebeat与Elasticsearch集群直连配置方法
—————————————-
http://kibana.cmdschool.org:5601/app/home#/tutorial/logstashLogs
Filebeat的配置
——————
https://www.elastic.co/guide/en/beats/filebeat/current/howto-guides.html
Filebeat索引名称配置
——————-
https://www.elastic.co/guide/en/beats/filebeat/current/change-index-name.html
Elastic Kibana postfix
———————–
https://github.com/ActionScripted/elastic-kibana-postfix
filebeat module postfix
————————-
https://github.com/maurom/filebeat-module-postfix
没有评论