Filebeat能输出文件日志到ES,但是ES7以后,默认是开启了ILM的,因此,而这种开启了ILM策略的输出默认是以filebeat开头,日期结尾,00001开始的索引结束。
很多时候,用户并不想按照这个标准输出,想设置自己的indexname, 本文将作重点讲解
那么在实践过程中主要是经常报如下错误:
“”Exiting: setup.template.name and setup.template.pattern have to be set if index name is modified“”,然后启动随机停止。服务中断。
原因:主要是setup配置项格式没顶格写导致。setup开头的三个是外层的配置项,不属于output.
filebeat.inputs:
# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.
- type: log
# Change to true to enable this input configuration.
enabled: true # 这里要开启,否则没有日志输出
# Paths that should be crawled and fetched. Glob based paths.
paths:
/var/log/secure #定义收集日志文件,
# 注意这里的配置 格式非常重要。
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["172.16.96.21:9200"]
# Authentication credentials - either API key or username/password.
username: "elastic"
password: "youpassword"
index: "nginx-%{+yyyy.MM.dd}" #这个索引名一定是跟在output下面里边,不要写错。
# setup.template.name: "default@template" # 下面三项 这里一定要顶格写,否则报错。
# setup.template.pattern: "nginx-*"
# setup.ilm.enabled: false
如果,index 索引格式位置错误,输出内容就是这样,也是有问题。
只有上面正确调整后,才能正常输出,如下:
腾讯云 这边有直接简单应用filebeats,大家可以直接选用,如果CVM与ES不在同VPC,通过对等链接打通后也是可以直接使用该收集器进行日志收集。
https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-template.html
https://www.cnblogs.com/zyxnhr/p/12214706.html
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。