logstash grok filter-grok 解析失败
logstash grok filter-grok parse failure
我有多行自定义日志,我通过 filebeat multiline 关键字将其处理为单行。现在这包括每行末尾的 \n 。然而,这会导致我的 logstsash 配置文件中的 grok 解析失败。有人可以帮我解决这个问题吗?以下是它们的外观:
请帮助我使用以下行的 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*************************************************************************
您可以在这里找到答案:
https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html
您应该使用 Mutate 块将所有 "\n"
替换为 ""
(空字符串)。
或者使用这个
%{DATESTAMP} %{WORD:time} %{GREEDYDATA}
正如@Mohsen 所建议的那样,您可能必须使用 gsub 过滤器来替换日志行中的所有 换行 字符。
filter {
mutate {
gsub => [
# replace all forward slashes with underscore
"fieldname", "\n", ""
]
}
}
也许您也可以在 if
条件下执行上述操作,以确保没有任何 grokparse
失败。
if "_grokparsefailure" in [tags] or "_dateparsefailure" in [tags] {
drop { }
}else{
mutate {
gsub => [
# replace all forward slashes with underscore
"fieldname", "\n", ""
]
}
}
希望对您有所帮助!
我有多行自定义日志,我通过 filebeat multiline 关键字将其处理为单行。现在这包括每行末尾的 \n 。然而,这会导致我的 logstsash 配置文件中的 grok 解析失败。有人可以帮我解决这个问题吗?以下是它们的外观:
请帮助我使用以下行的 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*************************************************************************
您可以在这里找到答案:
https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html
您应该使用 Mutate 块将所有 "\n"
替换为 ""
(空字符串)。
或者使用这个
%{DATESTAMP} %{WORD:time} %{GREEDYDATA}
正如@Mohsen 所建议的那样,您可能必须使用 gsub 过滤器来替换日志行中的所有 换行 字符。
filter {
mutate {
gsub => [
# replace all forward slashes with underscore
"fieldname", "\n", ""
]
}
}
也许您也可以在 if
条件下执行上述操作,以确保没有任何 grokparse
失败。
if "_grokparsefailure" in [tags] or "_dateparsefailure" in [tags] {
drop { }
}else{
mutate {
gsub => [
# replace all forward slashes with underscore
"fieldname", "\n", ""
]
}
}
希望对您有所帮助!