Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit c6d01da

Browse files
committed
Handle bi-directional flows from Cisco ASA
1 parent 3413aa8 commit c6d01da

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

logstash/conf.d/20_filter.logstash.conf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,15 @@ filter {
184184
id => "netflow-v9-normalize-bytes-from-in_permanent_bytes"
185185
rename => { "[netflow][in_permanent_bytes]" => "[netflow][bytes]" }
186186
}
187+
} else if [netflow][fwd_flow_delta_bytes] or [netflow][rev_flow_delta_bytes] {
188+
ruby {
189+
id => "netflow-v9-normalize-bytes-from-fwd-rev-bytes"
190+
code => "
191+
event.set( '[netflow][bytes]', event.get('[netflow][fwd_flow_delta_bytes]').to_i + event.get('[netflow][rev_flow_delta_bytes]').to_i )
192+
"
193+
}
187194
}
195+
188196
if [netflow][bytes] {
189197
mutate {
190198
id => "netflow-v9-normalize-convert-bytes"
@@ -208,7 +216,15 @@ filter {
208216
id => "netflow-v9-normalize-packets-from-in_permanent_pkts"
209217
rename => { "[netflow][in_permanent_pkts]" => "[netflow][packets]" }
210218
}
219+
} else if [netflow][initiatorPackets] or [netflow][responderPackets] {
220+
ruby {
221+
id => "netflow-v9-normalize-packets-from-init-resp-pkts"
222+
code => "
223+
event.set( '[netflow][packets]', event.get('[netflow][initiatorPackets]').to_i + event.get('[netflow][responderPackets]').to_i )
224+
"
225+
}
211226
}
227+
212228
if [netflow][packets] {
213229
mutate {
214230
id => "netflow-v9-normalize-convert-packets"
@@ -262,6 +278,31 @@ filter {
262278
}
263279
}
264280

281+
# Attempt to populate netflow.last_switched and netflow.first_switched if not provided in raw data. Usually this is necessary for data from Cisco ASA.
282+
if ![netflow][last_switched] {
283+
if [netflow][event_time_msec] {
284+
date {
285+
id => "netflow-v9-normalize-lastsw-from-event_time_msec"
286+
match => ["[netflow][event_time_msec]", "UNIX_MS"]
287+
target => "[netflow][last_switched]"
288+
}
289+
} else {
290+
mutate {
291+
id => "netflow-v9-normalize-lastsw-from-timestamp"
292+
add_field => { "[netflow][last_switched]" => "%{[@timestamp]}" }
293+
}
294+
}
295+
}
296+
if ![netflow][first_switched] {
297+
if [netflow][flow_start_msec] {
298+
date {
299+
id => "netflow-v9-normalize-firstsw-from-flow_start_msec"
300+
match => ["[netflow][flow_start_msec]", "UNIX_MS"]
301+
target => "[netflow][first_switched]"
302+
}
303+
}
304+
}
305+
265306
#--------------------
266307
# We now have a normalized flow record. The rest of the logic works
267308
# regardless of the Netflow version.

logstash/templates/netflow.template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"event_time_msec": {
9090
"path_match": "netflow.event_time_msec",
9191
"mapping": {
92-
"type": "long"
92+
"type": "date"
9393
}
9494
}
9595
},
@@ -153,7 +153,7 @@
153153
"flow_start_msec": {
154154
"path_match": "netflow.flow_start_msec",
155155
"mapping": {
156-
"type": "long"
156+
"type": "date"
157157
}
158158
}
159159
},

0 commit comments

Comments
 (0)