-
Notifications
You must be signed in to change notification settings - Fork 46
/
2600_filter_ecs.conf
139 lines (121 loc) · 4.07 KB
/
2600_filter_ecs.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
filter {
if [type] == "mod_security" {
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Align logs with Elastic ECS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mutate {
# Rename to existing ECS fields
rename => ["fqdn", "[host][hostname]"]
rename => ["requestHeaders.User-Agent", "[user_agent][original]"]
rename => ["httpMethod", "[http][request][method]"]
rename => ["requestedUri", "[url][path]"]
rename => ["sourceIp", "[client][ip]"]
rename => ["sourcePort", "[client][port]"]
rename => ["program", "[service][type]"]
rename => ["destIp", "[destination][ip]"]
rename => ["destPort", "[destination][port]"]
rename => ["uniqueId", "[tracing][trace][id]"]
# Rename to custom ECS fields
rename => ["requestHeaders", "[http][request][header]"]
rename => ["responseHeaders", "[http][response][header]"]
rename => ["auditLogTrailer", "[apache][mod_security][audit_log_trailer]"]
rename => ["rawSectionA", "[apache][mod_security][section][a]"]
rename => ["rawSectionB", "[apache][mod_security][section][b]"]
rename => ["rawSectionF", "[apache][mod_security][section][f]"]
rename => ["rawSectionH", "[apache][mod_security][section][h]"]
rename => ["matchedRules", "[apache][mod_security][matched_rule][raw]"]
rename => ["secRuleIds", "[apache][mod_security][matched_rule][id]"]
}
grok {
match => [ "incomingProtocol", "(HTTP\W)(%{NUMBER:http.version})" ]
}
grok {
match => [ "responseStatus", "(%{NUMBER:http.response.status_code:long} %{DATA})" ]
}
useragent { # workaround until ECS support is available: https://github.com/logstash-plugins/logstash-filter-useragent/issues/56
source => "[user_agent][original]"
target => "ua_tmp"
add_field => {
"[user_agent][device][name]" => "%{[ua_tmp][device]}"
"[user_agent][os][name]" => "%{[ua_tmp][os_name]}"
"[user_agent][name]" => "%{[ua_tmp][name]}"
}
}
# OS version ECS compatibility
if [ua_tmp][os_major] {
mutate {
add_field => {
"[user_agent][os][version]" => "%{[ua_tmp][os_major]}"
}
}
if [ua_tmp][os_minor] {
mutate {
replace => {
"[user_agent][os][version]" => "%{[user_agent][os][version]}.%{[ua_tmp][os_minor]}"
}
}
if [ua_tmp][os_patch] {
mutate {
replace => {
"[user_agent][os][version]" => "%{[user_agent][os][version]}.%{[ua_tmp][os_patch]}"
}
}
if [ua_tmp][os_build] {
mutate {
replace => {
"[user_agent][os][version]" => "%{[user_agent][os][version]}.%{[ua_tmp][os_build]}"
}
}
}
}
}
mutate {
add_field => {
"[user_agent][os][full]" => "%{[user_agent][os][name]} %{[user_agent][os][version]}"
}
}
}
# User agent version ECS compatibility
if [ua_tmp][major] {
mutate {
add_field => {
"[user_agent][version]" => "%{[ua_tmp][major]}"
}
}
if [ua_tmp][minor] {
mutate {
replace => {
"[user_agent][version]" => "%{[user_agent][version]}.%{[ua_tmp][minor]}"
}
}
if [ua_tmp][patch] {
mutate {
replace => {
"[user_agent][version]" => "%{[user_agent][version]}.%{[ua_tmp][patch]}"
}
}
if [ua_tmp][build] {
mutate {
replace => {
"[user_agent][version]" => "%{[user_agent][version]}.%{[ua_tmp][build]}"
}
}
}
}
}
}
mutate {
remove_field => ["ua_tmp"]
}
# geoip {
# source => "[client][ip]"
# target => "[client][geo]"
# database => "/var/lib/GeoIP/GeoIP2-City.mmdb"
# }
# geoip {
# source => "[client][ip]"
# target => "[client][as]"
# database => "/var/lib/GeoIP/GeoLite2-ASN.mmdb"
# }
}
}