Logstash 预期其中之一 #

Logstash expected one of #

我目前正在尝试 运行 使用以下配置文件的 Lostash:

input { 
    stdin { } 
} 
output { 
    rabbitmq { 
        exchange => "test_exchange" 
        exchange_type => "fanout" 
        host => "172.17.x.x" 
    } 
}

但是我收到一个错误:

logstash agent --configtest -f -config.conf

给我:

Error: Expected one of #, } at line 1, column 105 (byte 105) after output { rabbitmq { exchange => test_exchange exchange_type => fanout host => 172.17

当我在主机字段中放置类似 IP 的地址时,logstash 似乎有问题。我的配置有什么问题?

整个问题出在您创建 config.conf 文件时使用的方法。

您正在使用以下命令:

echo "input {stdin{}} output{rabbitmq{exchange=>"test_exchange" exchange_type =>"fanout" host=>"172.17.x.x"}}"

用双引号包围包含双引号的字符串不是一个好主意...

通过在字符串周围使用单引号,问题就解决了...

echo 'input {stdin{}} output{rabbitmq{exchange=>"test_exchange" exchange_type =>"fanout" host=>"172.17.x.x"}}'

真正的问题是 logstash 没有正确报告对配置文件的访问问题。这是 github 上的问题:

https://github.com/elastic/logstash/issues/2571

只需检查访问权限即可设置。