我目前正在尝试从我的日志文件中过滤特定的行。我在日志文件中的行具有以下模式。
[8/05/13 14:24:55.468] RuntimeErrorI E LaError
[8/05/13 14:24:55.468] AbcdEfg W SomeWarning
其中第一个是日期、时间、应用程序名称和日志级别(警告、错误、跟踪等),然后是错误消息或警告消息或任何其他消息。
所以我想要得到的只是日志级别错误,而不是其他日志级别。我有以下我正在玩的东西,但我根本没有得到控制台输出。我想我在 grep 的某个地方犯了一个错误来检查它是否 E(Error)
input {
file {
type => "database"
path => "/home/nakampe/Desktop/file.log"
}
}
filter {
grok {
pattern => "[%{MONTHDAY:date} / %{MONTH:month} / %{YEAR:year} %{TIME:time}] %WORD:application} %{WORD:levelType} %{WORD:message}"
}
#Here I want to only consider log levels of E (ERROR) and not others
grep{
match => ["levelType", "E"]
}
}
output {
elasticsearch {
embedded => true
}
stdout {
message => "%{@message}"
}
}