如何使用 Filebeat 8 连接 Easysearch

在日志场景,还是有很多小伙伴在使用 Filebeat 采集日志的。今天我来实战下使用 Filebeat 8 连接 Easysearch 。本次使用 Easysearch-1.9.0 版本和 Filebeat-8.17.0 版本做演示,也适用 Filebeat-oss-8.17.0 版本。
Easysearch 不开启兼容参数的情况
Easysearch 默认情况下未开启 Elastic 兼容功能。此时直接用 Filebeat 去连接 Easysearch 会失败,报错 "could not connect to a compatible version of Elasticsearch" ,直译过来就是“无法连接到兼容的 Elasticsearch 版本”。

Easysearch 开启 elasticsearch.api_compatibility 参数
在 Easysearch-1.9.0 中关于 Elasticsearch 的兼容性参数有两个,我们先开第一个。
启动 Filebeat 连接。

这次 Filebeat 检测到了一个兼容的版本 7.10.2,并导入了一个叫 filebeat 的索引生命周期管理策略,但最终因为无法导入模板而失败了。
索引生命周期查看。

关闭 Filebeat 的导入模板功能尝试连接,修改配置 filebeat.yml 关闭模板导入。

启动 Filebeat 连接 Easysearch。

这次 Filebeat 成功连接上了 Easysearch,并成功将采集数据写入。

Easysearch 同时开启两个兼容性参数
在 Easysearch-1.9.0 中关于 Elasticsearch 的兼容性参数有两个,这次我们二个同时打开。
清理测试数据后,启动 Filebeat 连接。

跟打开第一个兼容参数很像,只是 Filebeat 检测到的版本变成了 8.9.0。
我们关闭 Filebeat 的模板导入功能,再次连接——成功。

数据也成功写入。

注意事项
Easysearch 的第一个兼容参数 elasticsearch.api_compatibility 必须开启,否则 Filebeat 检测到的还是 1.9.0 版本无法正常连接。
如果 Easysearch 使用的是 1.9.0 之前的版本,可以使用网关代理 Easysearch 的方法。
总结
Easysearch-1.9.0 必须开启第一个兼容参数,此时检测到的版本是 7.10.2。也可同时开启两个兼容性参数,此时检测到的版本是 8.9.0。
Filebeat 必须关闭模板导入功能。
版权声明: 本文为 InfoQ 作者【极限实验室】的原创文章。
原文链接:【http://xie.infoq.cn/article/ae27ffe80e352ac91527e5c58】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论