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

handling IPv6 within square brackets #32989

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
- Fix file.path field in cloudtrail fileset to use json.digestS3Object. {pull}32759[32759]
- Fix rendering of MAC addresses to conform to ECS. {issue}32621[32621] {pull}32622[32622]
- Import dashboards from CEF integration. {pull}32766[32766]
- Fix how to handle IPv6 addresses in the fileset `nginx/ingress_controller` for Filebeat. {pull}32989[32989]

*Auditbeat*

Expand Down
5 changes: 5 additions & 0 deletions filebeat/module/nginx/ingress_controller/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
description: >
An array of upstream response status codes. It is a list because it is common that several upstream servers
were contacted during request processing.
- name: http.request.id
type: keyword
description: >
A unique identifier for each HTTP request to correlate logs between clients and servers in transactions.
The id may be contained in a non-standard HTTP header, such as X-Request-ID or X-Correlation-ID.
- name: http.request.length
type: long
format: bytes
Expand Down
37 changes: 28 additions & 9 deletions filebeat/module/nginx/ingress_controller/ingest/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ processors:
UPSTREAM_RESPONSE_LENGTH_LIST: (?:%{NUMBER})("?,?\s*(?:%{NUMBER}))*
UPSTREAM_RESPONSE_TIME_LIST: (?:%{NUMBER})("?,?\s*(?:%{NUMBER}))*
UPSTREAM_RESPONSE_STATUS_CODE_LIST: (?:%{NUMBER})("?,?\s*(?:%{NUMBER}))*
IP: (?:\[?%{IPV6}\]?|%{IPV4})
ignore_missing: true
- grok:
field: nginx.ingress_controller.info
Expand Down Expand Up @@ -139,18 +140,36 @@ processors:
for (def item : ctx.nginx.ingress_controller.upstream_address_list) {
last_upstream = item;
}
StringTokenizer tok = new StringTokenizer(last_upstream, ":");
if (tok.countTokens()>1) {
ctx.nginx.ingress_controller.upstream.ip = tok.nextToken();
ctx.nginx.ingress_controller.upstream.port = Integer.parseInt(tok.nextToken());
} else {
ctx.nginx.ingress_controller.upstream.ip = last_upstream;
}

ctx.nginx.ingress_controller.upstream.address = last_upstream;
}
catch (Exception e) {
ctx.nginx.ingress_controller.upstream.ip = null;
ctx.nginx.ingress_controller.upstream.port = null;
ctx.nginx.ingress_controller.upstream.address = null;
}
- grok:
field: nginx.ingress_controller.upstream.address
patterns:
- "^%{IPV4:nginx.ingress_controller.upstream.ip}:%{NUMBER:nginx.ingress_controller.upstream.port}$"
- "^\\[%{IPV6:nginx.ingress_controller.upstream.ip}\\]:%{NUMBER:nginx.ingress_controller.upstream.port}$"
- "^%{IPV6NOCOMPRESS:nginx.ingress_controller.upstream.ip}:%{NUMBER:nginx.ingress_controller.upstream.port}$"
- "^%{IPV6:nginx.ingress_controller.upstream.ip}%{IPV6PORTSEP}%{NUMBER:nginx.ingress_controller.upstream.port}$"
- "^%{IPV6:nginx.ingress_controller.upstream.ip}%{IPV6PORTSEP}%{POSINT:nginx.ingress_controller.upstream.port}$"
pattern_definitions:
IPV6NOCOMPRESS: '([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}'
IPV6PORTSEP: '(?: port |[p#.])'
ignore_missing: true
ignore_failure: true
gsantoro marked this conversation as resolved.
Show resolved Hide resolved
- convert:
field: nginx.ingress_controller.upstream.ip
gsantoro marked this conversation as resolved.
Show resolved Hide resolved
type: ip
ignore_missing: true
- convert:
field: nginx.ingress_controller.upstream.port
type: long
ignore_missing: true
- remove:
field: nginx.ingress_controller.upstream.address
ignore_failure: true
- script:
if: ctx.nginx?.ingress_controller?.remote_ip_list != null && ctx.nginx.ingress_controller.remote_ip_list.length > 0
lang: painless
Expand Down