Logstash json 过滤器不向事件的根添加字段 [已编辑]

Logstash json filter not adding fields to the root of the event [EDITED]

当我对消息使用 json 过滤器时,它神奇地消失了——永远不会到达 elasticsearch。当我移除过滤器时,一切正常。

样本_source-

{"message":"{\"id\":\"5563017afd801c1618603a7b\",\"date\":\"2015-05-23T15:30:00.000Z\",\"count\":485}","@version":"1","@timestamp":"2015-05-25T11:07:49.913Z","type":"app","env":"production","host":"production-server","tags":["event"]}

我使用节点应用程序,node-lumberjack-protocol 发送消息。

这是我的过滤器的样子

json {
    source => "message"
}

我做错了什么?

编辑

当我给 json 过滤器一个 target 时,消息被解析并添加到目标字段。但我不知道那是什么。我希望将 JSON 的字段添加到事件的根中。阅读 json 过滤器的 documentation,我认为如果我省略 target 就会发生这种情况,不幸的是它似乎并非如此。

Define the target field for placing the parsed data. If this setting is omitted, the JSON data will be stored at the root (top level) of the event.

您可以使用输入 codec 将 json 消息添加到根。

例如,

input {
        stdin{
                codec => json
        }
}

output {
        stdout { codec => rubydebug }
}

输入:

{"id":"5563017afd801c1618603a7b","date":"2015-05-23T15:30:00.000Z","count":485}

输出:

{
        "id" => "5563017afd801c1618603a7b",
      "date" => "2015-05-23T15:30:00.000Z",
     "count" => 485,
  "@version" => "1",
"@timestamp" => "2015-05-27T03:45:33.094Z",
      "host" => "BEN_LIM"
}