https://www.ibm.com/developerworks/cn/opensource/os-cn-elk-filebeat/index.html
ELK学习
Filebeat:
https://www.cnblogs.com/cjsblog/p/9445792.html
Beats是用于单用途数据托运人的平台。它们以轻量级代理的形式安装,并将来自成百上千台机器的数据发送到Logstash或Elasticsearch。
(画外音:通俗地理解,就是采集数据,并上报到Logstash或Elasticsearch)
Beats对于收集数据非常有用。它们位于你的服务器上,将数据集中在Elasticsearch中,Beats也可以发送到Logstash来进行转换和解析。
简单总结一下filebeat的配置使用:
其主要的配置项目有以下几项:
- 日志源的配置
- 接入ES及其模板配置(ES可视化工具Kibana)
- 接入Logstash
- 日志解析模板
日志源的配置
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log (可以指定一个或多个文件的接入)
ES接入
output.elasticsearch:
hosts: ["192.168.1.42:9200"]
此外Kibana接入:
setup.kibana:
host: "localhost:5601"
以及带验证的接入:
output.elasticsearch:
hosts: ["myEShost:9200"]
username: "filebeat_internal"
password: "{pwd}"
setup.kibana:
host: "mykibanahost:5601"
username: "my_kibana_user"
password: "{pwd}"
LogStash接入
output.logstash:
hosts: ["127.0.0.1:5044"]
解析模板配置
filebeat模板:
setup.template.name: "your_template_name"
setup.template.fields: "path/to/fields.yml"
覆盖一个已存在的模板
setup.template.overwrite: true
禁用自动加载模板
setup.template.enabled: false
修改索引名称
默认情况下,Filebeat写事件到名为filebeat-6.3.2-yyyy.MM.dd的索引,其中yyyy.MM.dd是事件被索引的日期。为了用一个不同的名字,你可以在Elasticsearch输出中设置index选项。例如:
output.elasticsearch.index: "customname-%{[beat.version]}-%{+yyyy.MM.dd}"
setup.template.name: "customname"
setup.template.pattern: "customname-*"
setup.dashboards.index: "customname-*"
配置示例
#=========================== Filebeat inputs ==============
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
#============================== Dashboards(仪表盘与可视化示例) ===============
setup.dashboards.enabled: false
#============================== Kibana ==================
setup.kibana:
host: "192.168.101.5:5601"
#-------------------------- Elasticsearch output ---------
output.elasticsearch:
hosts: ["localhost:9200"]