0

我面临一个我自己无法解决的配置失败,试图通过文档获得解决方案,但没有运气。

我有几个不同的主机,它们通过 collectd 将它们的指标发送到 logstash。在 logstash 配置中,我想将每个主机分开并将其通过管道传输到自己的 ES-index 中。当我尝试对我的设置进行配置测试时,logstash 会失败 - 也许有人可以帮助我。

分隔应由 collectd 提供的主机名触发:

[这是一个旧的原始 json 输出,所以请不要介意设置错误的索引]

{
  "_index": "wv-metrics",
  "_type": "logs",
  "_id": "AVHyJunyGanLcfwDBAon",
  "_score": null,
  "_source": {
    "host": "somefqdn.com",
    "@timestamp": "2015-12-30T09:10:15.211Z",
    "plugin": "disk",
    "plugin_instance": "dm-5",
    "collectd_type": "disk_merged",
    "read": 0,
    "write": 0,
    "@version": "1"
  },
  "fields": {
    "@timestamp": [
      1451466615211
    ]
  },
  "sort": [
    1451466615211
  ]
} 

请看我的配置:

输入配置(工作至今)

input {
  udp {
    port => 25826
    buffer_size => 1452
    codec => collectd { }
  }
}

输出配置文件:

filter {
if [host] == "somefqdn.com" {
output {
  elasticsearch {
   hosts => "someip:someport"
   user => logstash
   password => averystrongpassword
   index => "somefqdn.com"
                }
          }
     }
}

抛出的错误:

root@test-collectd1:/home/username# service logstash configtest
Error: Expected one of #, => at line 21, column 17 (byte 314) after filter {
if [host] == "somefqdn.com" {
output {
  elasticsearch

我了解,我的配置中可能缺少一个字符,但我找不到它。

提前谢谢!

4

1 回答 1

0

我在快速扫描中发现了两个错误:

首先,您的输出节不应使用 filter{} 块包装。

其次,您的输出节应以 output{} 开头(将条件放在里面):

output {
    if [host] == "somefqdn.com" {
        elasticsearch {
            ...
        }
    }
}
于 2015-12-30T09:18:40.537 回答