最近启用filebeat连ES的时候报错:couldn't connect to any of the configured Elasticsearch hosts

提示无法连接,原因有2个:

原因一: ES配置了密码认证,filebeat里面也需要配置对应的将账号密码配置进去;

output.elasticsearch:
  hosts: ["<es_url>"]
  username: "elastic"
  password: "<password>"
setup.kibana:
  host: "<kibana_url>"

原因二:从库使用命令行请求ES,发现连接拒绝;

 查看配置发现是ES 默认localhost访问,其他机器要访问需要修改配置

ES elasticsearch.yml 末尾添加配置

network.host: 0.0.0.0

Kibana也需要添加配置

server.host: "0.0.0.0"

重启生效后curl访问测试:

 启动filebeat:

filebeat setup
Overwriting ILM policy is disabled. Set `setup.ilm.overwrite: true` for enabling.

Index setup finished.
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
Setting up ML using setup --machine-learning is going to be removed in 8.0.0. Please use the ML app instead.
See more: https://www.elastic.co/guide/en/machine-learning/current/index.html
Loaded machine learning job configurations
Loaded Ingest pipelines

ES日志可以看到已经成功加载

[2021-11-17T10:19:27,234][INFO ][o.e.x.i.a.TransportPutLifecycleAction] [xxxxL] adding index lifecycle policy [filebeat]
[2021-11-17T10:19:29,564][INFO ][o.e.c.m.MetadataIndexTemplateService] [xxxxL] adding template [filebeat-7.15.1] for index patterns [filebeat-7.15.1-*]
[2021-11-17T10:19:29,934][INFO ][o.e.c.m.MetadataCreateIndexService] [xxxxL] [filebeat-7.15.1-2021.11.17-000001] creating index, cause [api], templates [filebeat-7.15.1], shards [1]/[1]
[2021-11-17T10:19:30,206][INFO ][o.e.x.i.IndexLifecycleTransition] [xxxxL] moving index [filebeat-7.15.1-2021.11.17-000001] from [null] to [{"phase":"new","action":"complete","name":"complete"}] in policy [filebeat]
[2021-11-17T10:19:30,366][INFO ][o.e.x.i.IndexLifecycleTransition] [xxxxL] moving index [filebeat-7.15.1-2021.11.17-000001] from [{"phase":"new","action":"complete","name":"complete"}] to [{"phase":"hot","action":"unfollow","name":"branch-check-unfollow-prerequisites"}] in policy [filebeat]
[2021-11-17T10:19:30,642][INFO ][o.e.x.i.IndexLifecycleTransition] [xxxxL] moving index [filebeat-7.15.1-2021.11.17-000001] from [{"phase":"hot","action":"unfollow","name":"branch-check-unfollow-prerequisites"}] to [{"phase":"hot","action":"rollover","name":"check-rollover-ready"}] in policy [filebeat]

[INFO ][o.e.c.m.MetadataIndexTemplateService] [xxxxL] adding template [filebeat-7.15.1] for index patterns [filebeat-7.15.1-*]

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐