带输出的 FileBeat 配置测试

Rag*_*eer 2 filebeat

我正在尝试使用filebeat test ouput -e -c filebeat.yml我只看到带有命令列表的帮助消息来测试我的配置。

我实际上是在尝试输出数据文件进行验证。虽然我已经测试过filebeat test config -e -c filebeat.yml了。

Ale*_*uma 10

假设您使用的是 filebeat 6.x(这些测试是在 CentOS 7.5 系统中使用 filebeat 6.5.0 完成的)

要测试您的 filebeat 配置(语法),您可以执行以下操作:

[root@localhost ~]# filebeat test config
Config OK
Run Code Online (Sandbox Code Playgroud)

如果你刚刚下载了 tarball,它默认使用 untared filebeat 目录中的 filebeat.yml。如果您安装了 RPM,它会使用 /etc/filebeat/filebeat.yml。

如果要定义不同的配置文件,可以执行以下操作:

[root@localhost ~]# filebeat test config -c /etc/filebeat/filebeat2.yml
Config OK
Run Code Online (Sandbox Code Playgroud)

要测试输出块(即:如果您连接到 elasticsearch 实例或 kafka 代理),您可以执行以下操作:

[root@localhost ~]# filebeat test output
elasticsearch: http://localhost:9200...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... OK
    addresses: ::1, 127.0.0.1
    dial up... ERROR dial tcp [::1]:9200: connect: connection refused
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我的 localhost elasticsearch 已关闭,因此 filebeat 会抛出一个错误,指出它无法连接到我的输出块。

和语法验证(test config)一样,可以为输出连接测试提供不同的配置文件:

[root@localhost ~]# filebeat test output -c /etc/filebeat/filebeat2.yml
logstash: localhost:5044...
  connection...
    parse host... OK
    dns lookup... OK
    addresses: ::1, 127.0.0.1
    dial up... ERROR dial tcp [::1]:5044: connect: connection refused
Run Code Online (Sandbox Code Playgroud)

在此备用配置文件中,我的输出块也无法连接到 logstash 实例。