Skip to content

Commit a65463e

Browse files
authored
cisco_meraki: improve handling of flows events (#4352)
Simplify the handling of the line by using grok from the outset, reducing the number of machines needing to be instantiated and increasing the flexibility of the inputs that can be parsed.
1 parent 5af3ccc commit a65463e

File tree

5 files changed

+155
-57
lines changed

5 files changed

+155
-57
lines changed

packages/cisco_meraki/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.2.3"
3+
changes:
4+
- description: Improve handling of flows events.
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/issues/4352
27
- version: "1.2.2"
38
changes:
49
- description: Remove duplicate fields.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<134>1 1647478988.289402144 MX84_4 flows allow src=10.0.2.170 dst=10.0.0.34 mac=00:7C:2D:BD:76:F2 protocol=udp sport=54841 dport=15600
22
<134>1 1647478988.476061795 MX84 flows src=216.160.83.57 dst=216.160.83.61 protocol=tcp sport=54445 dport=44210 pattern: 1 all
33
<134>1 1647478988.596151424 MX84_7 flows allow src=10.0.0.34 dst=10.0.0.234 mac=64:1C:B0:BA:F0:EC protocol=tcp sport=49761 dport=15500
4+
<134>1 1664382879.496990921 AP_XXXX flows allow src=fe80::1021:83ca:b68:4cd8 dst=ff02::1:ffb6:a227 mac=28:FF:3C:AB:DB:AA protocol=icmp6 type=135
5+
<134>1 1664385452.707589827 AP_XXXX flows allow src=172.16.12.23 dst=224.0.0.2 mac=4C:AB:4F:0D:3D:AA protocol=2
6+
<134>1 1664385453.129104346 AP_XXXX flows allow src=172.16.10.14 dst=81.2.69.144 mac=EC:63:D7:0F:6B:AA protocol=icmp type=8

packages/cisco_meraki/data_stream/log/_dev/test/pipeline/test-flows.log-expected.json

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,144 @@
157157
"forwarded",
158158
"preserve_original_event"
159159
]
160+
},
161+
{
162+
"@timestamp": "2022-09-28T16:34:39.496Z",
163+
"cisco_meraki": {
164+
"event_subtype": "flow_allowed",
165+
"event_type": "flows",
166+
"flows": {
167+
"op": "allow"
168+
}
169+
},
170+
"destination": {
171+
"ip": "ff02::1:ffb6:a227"
172+
},
173+
"ecs": {
174+
"version": "8.4.0"
175+
},
176+
"event": {
177+
"action": "layer3-firewall-allowed-flow",
178+
"category": [
179+
"network"
180+
],
181+
"original": "\u003c134\u003e1 1664382879.496990921 AP_XXXX flows allow src=fe80::1021:83ca:b68:4cd8 dst=ff02::1:ffb6:a227 mac=28:FF:3C:AB:DB:AA protocol=icmp6 type=135",
182+
"type": [
183+
"info",
184+
"connection",
185+
"start"
186+
]
187+
},
188+
"network": {
189+
"protocol": "icmp6"
190+
},
191+
"observer": {
192+
"hostname": "AP_XXXX"
193+
},
194+
"source": {
195+
"ip": "fe80::1021:83ca:b68:4cd8",
196+
"mac": "28-FF-3C-AB-DB-AA"
197+
},
198+
"tags": [
199+
"forwarded",
200+
"preserve_original_event"
201+
]
202+
},
203+
{
204+
"@timestamp": "2022-09-28T17:17:32.707Z",
205+
"cisco_meraki": {
206+
"event_subtype": "flow_allowed",
207+
"event_type": "flows",
208+
"flows": {
209+
"op": "allow"
210+
}
211+
},
212+
"destination": {
213+
"ip": "224.0.0.2"
214+
},
215+
"ecs": {
216+
"version": "8.4.0"
217+
},
218+
"event": {
219+
"action": "layer3-firewall-allowed-flow",
220+
"category": [
221+
"network"
222+
],
223+
"original": "\u003c134\u003e1 1664385452.707589827 AP_XXXX flows allow src=172.16.12.23 dst=224.0.0.2 mac=4C:AB:4F:0D:3D:AA protocol=2",
224+
"type": [
225+
"info",
226+
"connection",
227+
"start"
228+
]
229+
},
230+
"network": {
231+
"protocol": "2"
232+
},
233+
"observer": {
234+
"hostname": "AP_XXXX"
235+
},
236+
"source": {
237+
"ip": "172.16.12.23",
238+
"mac": "4C-AB-4F-0D-3D-AA"
239+
},
240+
"tags": [
241+
"forwarded",
242+
"preserve_original_event"
243+
]
244+
},
245+
{
246+
"@timestamp": "2022-09-28T17:17:33.129Z",
247+
"cisco_meraki": {
248+
"event_subtype": "flow_allowed",
249+
"event_type": "flows",
250+
"flows": {
251+
"op": "allow"
252+
}
253+
},
254+
"destination": {
255+
"geo": {
256+
"city_name": "London",
257+
"continent_name": "Europe",
258+
"country_iso_code": "GB",
259+
"country_name": "United Kingdom",
260+
"location": {
261+
"lat": 51.5142,
262+
"lon": -0.0931
263+
},
264+
"region_iso_code": "GB-ENG",
265+
"region_name": "England"
266+
},
267+
"ip": "81.2.69.144"
268+
},
269+
"ecs": {
270+
"version": "8.4.0"
271+
},
272+
"event": {
273+
"action": "layer3-firewall-allowed-flow",
274+
"category": [
275+
"network"
276+
],
277+
"original": "\u003c134\u003e1 1664385453.129104346 AP_XXXX flows allow src=172.16.10.14 dst=81.2.69.144 mac=EC:63:D7:0F:6B:AA protocol=icmp type=8",
278+
"type": [
279+
"info",
280+
"connection",
281+
"start"
282+
]
283+
},
284+
"network": {
285+
"protocol": "icmp"
286+
},
287+
"observer": {
288+
"hostname": "AP_XXXX"
289+
},
290+
"source": {
291+
"ip": "172.16.10.14",
292+
"mac": "EC-63-D7-0F-6B-AA"
293+
},
294+
"tags": [
295+
"forwarded",
296+
"preserve_original_event"
297+
]
160298
}
161299
]
162300
}
Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,24 @@
11
---
22
description: Pipeline for Cisco Meraki flows message type
33
processors:
4-
- dissect:
5-
description: Determine if the token is src= or operation
6-
field: event.original
7-
pattern: "%{} %{} %{} %{} %{_temp.token} %{}"
8-
- dissect:
9-
description: Case for src= follows flows keyword
10-
field: event.original
11-
pattern: "%{} flows %{*src}=%{&src} %{*dst}=%{&dst} %{*prot}=%{&prot} %{*sport}=%{&sport} %{*dport}=%{&dport} %{}"
12-
if: ctx._temp.token.startsWith("src=") == true
13-
- dissect:
14-
description: Case for firewall action prepends src=
15-
field: event.original
16-
pattern: "%{} flows %{cisco_meraki.flows.op} %{*src}=%{&src} %{*dst}=%{&dst} %{*mac}=%{&mac} %{*prot}=%{&prot} %{*sport}=%{&sport} %{*dport}=%{&dport}"
17-
if: ctx._temp.token.startsWith("src=") == false
184
- grok:
19-
field: src
20-
patterns:
21-
- "^%{IPV4:src}$"
22-
- "^%{IPV6:src}$"
23-
if: ctx?.src != null
24-
- convert:
25-
type: ip
26-
field: src
27-
target_field: source.ip
28-
ignore_failure: true
29-
- grok:
30-
field: dst
5+
field: event.original
316
patterns:
32-
- "^%{IPV4:dst}$"
33-
- "^%{IPV6:dst}$"
34-
if: ctx?.dst != null
35-
- convert:
36-
type: ip
37-
field: dst
38-
target_field: destination.ip
39-
ignore_failure: true
40-
- rename:
41-
field: protocol
42-
target_field: network.protocol
43-
- convert:
44-
field: sport
45-
target_field: source.port
46-
type: long
47-
if: ctx?.sport != "0"
48-
ignore_failure: true
49-
- convert:
50-
field: dport
51-
target_field: destination.port
52-
type: long
53-
if: ctx?.dport != "0"
54-
ignore_failure: true
7+
- "flows( %{NOTSPACE:cisco_meraki.flows.op})? src=%{IP:source.ip:ip} dst=%{IP:destination.ip:ip}( mac=%{MAC:source.mac})? protocol=%{NOTSPACE:network.protocol}( sport=%{NONNEGINT:source.port:long})?( dport=%{NONNEGINT:destination.port:long})?"
558
- gsub:
56-
field: mac
57-
target_field: source.mac
58-
pattern: '[-:.]'
9+
field: source.mac
10+
pattern: '[:.]'
5911
replacement: '-'
60-
if: ctx._temp.token.startsWith("src=") == false
12+
ignore_missing: true
6113
- set:
6214
field: cisco_meraki.event_subtype
6315
value: "ip_session_initiated"
64-
if: ctx._temp.token.startsWith("src=") == true
16+
if: ctx.cisco_meraki?.flows?.op == null
6517
- set:
6618
field: cisco_meraki.event_subtype
6719
value: "flow_allowed"
68-
if: ctx._temp.token.startsWith("src=") == false && ctx?.cisco_meraki?.flows?.op == 'allow'
20+
if: ctx.cisco_meraki?.flows?.op == 'allow'
6921
- set:
7022
field: cisco_meraki.event_subtype
7123
value: "flow_denied"
72-
if: ctx._temp.token.startsWith("src=") == false && ctx?.cisco_meraki?.flows?.op == 'deny'
24+
if: ctx.cisco_meraki?.flows?.op == 'deny'

packages/cisco_meraki/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: 1.0.0
22
name: cisco_meraki
33
title: Cisco Meraki
4-
version: 1.2.2
4+
version: 1.2.3
55
license: basic
66
description: Collect logs from Cisco Meraki with Elastic Agent.
77
type: integration

0 commit comments

Comments
 (0)