-
Notifications
You must be signed in to change notification settings - Fork 46
/
logstash-metadata.conf
49 lines (40 loc) · 1021 Bytes
/
logstash-metadata.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
input {
stdin { }
}
filter {
# initialize metadata field used as flag
mutate {
add_field => { "[@metadata][foundtype]" => "" }
}
# try to match 'hello' looking messages
if "" == [@metadata][foundtype] {
grok {
match => { "message" => "hello %{GREEDYDATA:[@metadata][myname]}" }
break_on_match => false
add_field => { "[@metadata][foundtype]" => "hellotype" }
add_tag => [ "didhello" ]
}
}
# try to match 'bye' looking messages
if "" == [@metadata][foundtype] {
grok {
match => { "message" => "bye %{GREEDYDATA:[@metadata][myname]}" }
break_on_match => false
add_field => { "[@metadata][foundtype]" => "byetype" }
add_tag => [ "didbye" ]
}
}
# add description based on flag
if !("" == [@metadata][foundtype]) {
mutate {
add_field => { "description" => "action performed by %{[@metadata][myname]}" }
}
}else {
mutate {
add_field => { "description" => "this was not a hello or bye message type" }
}
}
} # filter
output {
stdout { codec => rubydebug }
}