-
Notifications
You must be signed in to change notification settings - Fork 45
/
2082_filter_section_h_extract_stopwatch.conf
53 lines (46 loc) · 1.49 KB
/
2082_filter_section_h_extract_stopwatch.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
filter {
if [type] == "mod_security" {
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Promote raw "stopwatch" in section H
# to a real date. The value is in microseconds
# since epoch (convert to seconds) then
# run through logstashes' routine. The result
# of this is that the logstash @timestamp is converted
# to be the modsec stopwatch timestamp value. We
# also retain the milliseconds and seconds fields
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
grok {
match => {
"rawSectionH" => "Stopwatch: %{WORD:event_date_microseconds}"
}
}
mutate {
convert => [ "event_date_microseconds", "float" ]
}
# micro -> milli
ruby {
code => "
event_date_milliseconds = (event.get('event_date_microseconds').to_i / 1000.0)
event.set('event_date_milliseconds', event_date_milliseconds)
"
}
# milli -> seconds
ruby {
code => "
event_date_seconds = (event.get('event_date_milliseconds').to_i / 1000.0)
event.set('event_date_seconds', event_date_seconds)
"
}
# NOTE!, this forces the event's @timestamp to be = to the stopwatch value
date {
match => [ "event_date_seconds", "UNIX" ]
timezone => "GMT"
}
# a second copy of a iso8601 date
ruby {
code => "
event.set('event_timestamp', (Time.at(event.get('event_date_seconds')).gmtime).iso8601(3))
"
}
}
}