ELK配置之,filebeat更改自定义索引名称

✍️Auth:star皆空       Date:2021/12/17       Cat:Linux服务器       👁️:1,956 次浏览

简介:

filebeat客户端添加成功后,在kibana查看添加的索引,默认情况下,当索引生命周期管理(ILM)被禁用或不受支持时,Filebeat 使用时间序列索引。索引命名格式为 filebeat-7.16.1-yyyy.MM.dd。

如图所示:

一台filebeat还好,可以清楚的分辨,但当多台机器添加后,共用一个索引名,无法分辨,这时需要自定义索引名称。有两种方法更改索引名称。

方法一:

在filebeat.yml文件中,配置setup.template.namesetup.template.pattern选项以匹配新名称。

sudo vim /etc/filebeat/filebeat.yml

添加以下选项,这里将索引名称改为elk-file

output.elasticsearch.index: "elk-file-%{[agent.version]}-%{+yyyy.MM.dd}"
setup.template.name: "elk-file"
setup.template.pattern: "elk-file-*"
setup.ilm.enabled: false

重启filebeat,索引名称格式变成,elk-file-7.16.1-yyyy.MM.dd

注:从7.0版本开始,索引生命周期管理(ILM)默认是开启状态,当开启状态时候,setup.template.name
setup.template.pattern两个参数不生效,所以还需要配置关闭ILM,即setup.ilm.enabled: false

官方参考文档:https://www.elastic.co/guide/en/beats/filebeat/current/change-index-name.html

方法二:

索引生命周期管理(ILM)默认是开启状态,在不关闭ILM情况下更改索引名称。在配置文件filebeat.yml添加以下选项即可。

setup.ilm.enabled: auto
setup.ilm.rollover_alias: "elk-file"
setup.ilm.pattern: "{now/d}-000001" 

重启后,索引名称为elk-file-yyyy.MM.dd-000001 格式。

官方参考文档:https://www.elastic.co/guide/en/beats/filebeat/current/ilm.html

打赏作者

发表评论