Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[netflow]: Append all ip addresses found to the related.ip field. #11193

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/netflow/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# newer versions go on top
- version: "2.19.0"
changes:
- description: Append all ip addresses found to related.ip field.
type: enhancement
link: https://github.com/elastic/integrations/pull/11193
- version: "2.18.0"
changes:
- description: Update package spec to 3.0.3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3224,8 +3224,8 @@
},
"related": {
"ip": [
"10.36.236.100",
"10.127.32.11"
"10.127.32.11",
"10.36.236.100"
]
},
"source": {
Expand Down Expand Up @@ -3496,7 +3496,9 @@
},
"related": {
"ip": [
"0.0.0.0"
"0.0.0.0",
"2a02:cf40::1",
"2a02:cf40::2"
]
},
"source": {
Expand Down Expand Up @@ -3574,7 +3576,9 @@
},
"related": {
"ip": [
"0.0.0.0"
"0.0.0.0",
"2a02:cf40::1",
"2a02:cf40::2"
]
},
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@ processors:
- network
- session
if: ctx.event?.category != null && ctx.event?.category == "network_session"
- script:
description: Collect all related ip addresses
tag: script_collect_related_ip
lang: painless
source: |
HashSet set = null;
for (key in ctx.netflow.keySet()) {
if (key.endsWith("_ipv4_address") || key.endsWith("_ipv6_address")) {
// Creating set on demand, avoiding extra garbage
if (set == null) {
set = new HashSet();
}
set.add(ctx.netflow[key]);
}
}

if (set != null) {
if (ctx.related == null) {
ctx.related = new HashMap();
}
if (ctx.related?.ip != null) {
for (ip in ctx.related.ip) {
set.add(ip);
}
}

ArrayList list = new ArrayList(set);
Collections.sort(list);
ctx.related.ip = list;
}

if: ctx.netflow instanceof Map
- set:
field: network.type
value: ipv4
Expand Down
2 changes: 1 addition & 1 deletion packages/netflow/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
format_version: "3.0.3"
name: netflow
title: NetFlow Records
version: "2.18.0"
version: "2.19.0"
description: Collect flow records from NetFlow and IPFIX exporters with Elastic Agent.
type: integration
categories:
Expand Down