Batch file Logstash exec输入插件-从@message中删除命令运行

Batch file Logstash exec输入插件-从@message中删除命令运行,batch-file,logstash,logstash-configuration,Batch File,Logstash,Logstash Configuration,我正在windows计算机上使用logstash 1.5.1。我必须进行一个rest调用,它为我提供JSON输出 因此,我使用exec。结果不再是json:-( 此事件的@message将作为命令的整个stdout 一件事。 我的日志存储配置 input { exec { command => "C:\bin\curl\curl.exe http://localhost:8080/jolokia/read/metrics:name=trx.process.appr

我正在windows计算机上使用logstash 1.5.1。我必须进行一个rest调用,它为我提供JSON输出

因此,我使用exec。结果不再是json:-(

此事件的@message将作为命令的整个stdout 一件事。

我的日志存储配置

input {
    exec {
        command => "C:\bin\curl\curl.exe http://localhost:8080/jolokia/read/metrics:name=trx.process.approved" 
        interval => 10
        codec => json { charset => "CP1252" }
    }
}
output {
  elasticsearch {
    node_name => test
    host => myhost  
  }
}
cmd下的输出

{"request":{"mbean":"metrics:name=trx.process.approved","type":"read"},"value":{"Count":14},"timestamp":1434643572,"status":200}
elasticsearch上不可解析的输出(3行!)

欢迎指点

最后,我只想将这一行发送到elasticsearch:

{"request":{"mbean":"metrics:name=trx.process.approved","type":"read"},"value":{"Count":14},"timestamp":1434641808,"status":200}

我自己找到了解决办法

filter {
    split { 
    }
    if  [message] !~ "^{" {
        drop {}
    }
}
如果字符串不是以“{”开头,则将删除该行

{"request":{"mbean":"metrics:name=trx.process.approved","type":"read"},"value":{"Count":14},"timestamp":1434641808,"status":200}
filter {
    split { 
    }
    if  [message] !~ "^{" {
        drop {}
    }
}