Logstash _grokparsefailure

时间:2015-05-27 16:02:54

标签: logstash grok

有人能够增加一些清晰度吗?当我对grokdebug和grokconstructor测试它时,我的grok模式工作正常,但是我把它放在Logastash中它从一开始就失败了。任何指导将不胜感激。下面是我的过滤器和示例日志条目。

{"casename":"null","username":"null","startdate":"2015-05-26T01:09:23Z","enddate":"2015-05-26T01:09:23Z","time":"0.0156249","methodname":"null","url":"http://null.domain.com/null.php/null/jobs/_search?q=jobid:\"0\"&size=100&from=0","errortype":"null","errorinfo":"null","postdata":"null","methodtype":"null","servername":"null","gaggleid":"a51b90d6-1f82-46a7-adb9-9648def879c5","date":"2015-05-26T01:09:23Z","firstname":"null","lastname":"null"}


filter {
  if [type] == 'EventLog' {
    grok {
      match => { 'message' =>  ' \{"casename":"%{WORD:casename}","username":"%{WORD:username}","startdate":"%{TIMESTAMP_ISO8601:startdate}","enddate":"%{TIMESTAMP_ISO8601:enddate}","time":"%{NUMBER:time}","methodname":"%{WORD:methodname}","url":"%{GREEDYDATA:url}","errortype":"%{WORD:errortype}","errorinfo":"%{WORD:errorinfo}","postdata":"%{GREEDYDATA:postdata}","methodtype":"%{WORD:methodtype}","servername":"%{HOST:servername}","gaggleid":"%{GREEDYDATA:gaggleid}","date":"%{TIMESTAMP_ISO8601:date}","firstname":"%{WORD:firstname}","lastname":"%{WORD:lastname}"\} '
     }
   }
  }
 }

1 个答案:

答案 0 :(得分:1)

确实,“从一开始就失败了”!看到了吗?

'message' =>  ' \{"casename"

              ^^^

输入中没有初始(或尾随)空格,但您的模式中有空格。删除它们,它在logstash中工作正常。

是的,你见过json codecfilter吗?