我有一个生成的日志文件,其格式如下:
=======================================================
Debut du traitement vcc_0pg.sh - HISTORISATION DES FICHIERS LOGS le 15/07/05 00:30
Historisation des fichiers de log OK
=======================================================
我的配置文件是:
filter {
multiline{
pattern => "^Debut"
what => "previous"
negate=> true
}
if [type] == "prueba"{
grok{
match => ['message',"%{GREEDYDATA:content}"]
}
mutate {
replace => [ "message", "%{content}" ]
remove_field => ["content"]
}
}
if [message] == "^=" {
drop { }
}
}
我想获得第2部分,它包含两行(多行),而且我想删除第1部分和第3部分:
1: =======================================================
2: Debut du traitement vcc_0pg.sh - HISTORISATION DES FICHIERS LOGS le 15/07/05 00:30
Historisation des fichiers de log OK
3: =======================================================
答案 0 :(得分:1)
我解决了:
if [type] == "debut" {
if ([message] =~ "^=") {
drop {}
}
multiline {
pattern => "^Debut"
what => "previous"
negate=> "true"
}
if ("Debut" in [message])
{
grok {
match => [ "message", "Debut du traitement %{GREEDYDATA:file} -" ]
}
grok {
match => [ "message", "%{DATE_EU:date} %{HOUR:hour}:%{MINUTE:minute}" ]
}
mutate {
add_field => { "logdate" => "%{date} %{hour}:%{minute}" }
}
date {
locale => "fr"
timezone => "Europe/Paris"
match => ["logdate", "yy/MM/dd HH:mm"]
target => "logdate"
}
mutate
{
remove_field => [ "date" ]
remove_field => [ "hour" ]
remove_field => [ "minute" ]
}
}
}