简体   繁体   English

logstash grok filter-grok解析失败

[英]logstash grok filter-grok parse failure

I have multiline custom logs which I am processing as a single line by the filebeat multiline keyword. 我有多行自定义日志,我正在通过filebeat multiline关键字将其作为一行处理。 Now this includes \\n at the end of each line. 现在,每行末尾都包含\\ n。 This however causes grok parse failure in my logstsash config file. 但是,这会导致我的logstsash配置文件中的grok解析失败。 Can someone help me on this. 有人可以帮我吗 Here is how all of them look like: 它们都是这样的:

Please help me with the grok filter for the following line: 请为以下行的grok过滤器提供帮助:

11/18/2016 3:05:50 AM : \\nError thrown is:\\nEmpty Queue\\n*************************************************************************\\nRequest sent is:\\nhpi_hho_de,2015423181057,e06106f64e5c40b4b72592196a7a45cd\\n*************************************************************************\\nResponse received is:\\nQSS RMS Holds Hashtable is empty\\n************************************************************************* 2016/11/18 3:05:50:\\ n抛出的错误是:\\ n空队列\\ n ******************************** ********************************************** \\ n发送的请求是: \\ nhpi_hho_de,2015423181057,e06106f64e5c40b4b72592196a7a45cd \\ n ****************************************** *********************************** \\ n收到的响应为:\\ nQSS RMS保留哈希表为空\\ n ***** ****************************************************** ******************

As @Mohsen suggested you might have to use the gsub filter in order to replace all the new line characters in your log line. 如@Mohsen所建议,您可能必须使用gsub过滤器才能替换日志行中的所有新行字符。

filter {
  mutate {
    gsub => [
      # replace all forward slashes with underscore
      "fieldname", "\n", ""         
    ]
  }
}

Maybe you could also do the above within an if condition, to make sure that there's no any grokparse failure. 也许您也可以在if条件下执行上述操作,以确保没有出现grokparse故障。

if "_grokparsefailure" in [tags] or "_dateparsefailure" in [tags] {
    drop { }
}else{
  mutate {
    gsub => [
      # replace all forward slashes with underscore
      "fieldname", "\n", ""         
    ]
  }
}

Hope this helps! 希望这可以帮助!

you can find your answer here: 您可以在这里找到答案:

https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html https://www.elastic.co/guide/zh-CN/logstash/current/plugins-filters-mutate.html

you should use Mutate block to replace all "\\n" with "" (empty string). 您应该使用Mutate块将所有"\\n"替换为"" (空字符串)。 or use this 或使用这个

%{DATESTAMP} %{WORD:time} %{GREEDYDATA}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM