Skip to content

Commit b5e6530

Browse files
committed
feat: ELB routing and pipeline
Signed-off-by: Kavindu Dodanduwa <[email protected]>
1 parent 83291f8 commit b5e6530

File tree

5 files changed

+107
-2
lines changed

5 files changed

+107
-2
lines changed

packages/aws/data_stream/elb_logs/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ processors:
99
field: message
1010
target_field: event.original
1111
ignore_missing: true
12-
if: 'ctx.event?.original == null'
12+
if: ctx.event?.original == null
1313
description: 'Renames the original `message` field to `event.original` to store a copy of the original message. The `event.original` field is not touched if the document already has one; it may happen when Logstash sends the document.'
1414
- remove:
1515
field: message
1616
ignore_missing: true
17-
if: 'ctx.event?.original != null'
17+
if: ctx.event?.original != null
1818
description: 'The `message` field is no longer required if the document has an `event.original` field.'
1919
- grok:
20+
if: ctx?.event?.source != 'otel'
2021
field: event.original
2122
# Classic ELB patterns documented in https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/access-log-collection.html
2223
# ELB v2 Application load balancers https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html
@@ -182,6 +183,7 @@ processors:
182183
separator: ' '
183184
ignore_missing: true
184185
- date:
186+
if: ctx?.event?.source != 'otel'
185187
field: _tmp.timestamp
186188
formats:
187189
- ISO8601
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
description: "Pipeline for processing sample logs"
3+
4+
processors:
5+
- dot_expander:
6+
field: "*"
7+
path: attributes
8+
- dot_expander:
9+
field: "*"
10+
path: resource.attributes
11+
# Common fields
12+
- set:
13+
field: aws.elb.type
14+
copy_from: attributes.network.protocol.name
15+
- set:
16+
field: aws.elb.name
17+
copy_from: resource.attributes.cloud.resource_id
18+
- set:
19+
field: source.address
20+
copy_from: attributes.client.address
21+
- set:
22+
field: source.port
23+
copy_from: attributes.client.port
24+
- set:
25+
field: http.request.body.bytes
26+
copy_from: attributes.http.request.size
27+
- set:
28+
field: http.response.body.bytes
29+
copy_from: attributes.http.response.size
30+
- set:
31+
field: source.bytes
32+
copy_from: attributes.http.request.size
33+
- set:
34+
field: destination.bytes
35+
copy_from: attributes.http.response.size
36+
# Fields that may be missing between ALB, NLB & CLB
37+
- set:
38+
if: 'ctx?.attributes?.http?.request?.method != null'
39+
field: http.request.method
40+
copy_from: attributes.http.request.method
41+
- set:
42+
if: 'ctx?.attributes?.url?.full != null'
43+
field: _tmp.uri_orig
44+
copy_from: attributes.url.full
45+
- set:
46+
if: 'ctx?.attributes?.network?.protocol?.version != null'
47+
field: http.version
48+
copy_from: attributes.network.protocol.version
49+
- set:
50+
if: 'ctx?.attributes?.tls?.cipher != null'
51+
field: ssl_cipher
52+
copy_from: attributes.tls.cipher
53+
- set:
54+
if: 'ctx?.attributes?.tls?.protocol?.version != null'
55+
field: ssl_protocol
56+
copy_from: attributes.tls.protocol.version
57+
- set:
58+
if: 'ctx?.attributes?.aws?.elb?.tls?.listener?.resource_id != null'
59+
field: aws.elb.listener
60+
copy_from: attributes.aws.elb.tls.listener.resource_id
61+
- set:
62+
if: 'ctx?.attributes?.aws?.elb?.status?.code!= null'
63+
field: http.response.status_code
64+
copy_from: attributes.aws.elb.status.code
65+
# Drop OTel attributes
66+
- remove:
67+
field:
68+
- attributes
69+
- resource.attributes
70+
ignore_missing: true
71+
- set:
72+
field: event.source
73+
value: otel
74+
on_failure:
75+
- set:
76+
field: error.message
77+
value: '{{ _ingest.on_failure_message }}'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
- name: data_stream.type
2+
type: constant_keyword
3+
description: Data stream type.
4+
- name: data_stream.dataset
5+
type: constant_keyword
6+
description: Data stream dataset.
7+
- name: data_stream.namespace
8+
type: constant_keyword
9+
description: Data stream namespace.
10+
- name: '@timestamp'
11+
type: date
12+
description: Event timestamp.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title: "Route OTel AWS ELB logs to ECS"
2+
type: logs
3+
dataset: aws.elbaccess.otel
4+
elasticsearch:
5+
dynamic_dataset: true
6+
dynamic_namespace: true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- source_dataset: aws.elbaccess.otel
2+
rules:
3+
# Route to aws.elb_logs dataset if event parsing is successful
4+
- target_dataset: aws.elb_logs
5+
if: ctx?.event?.source == "otel"
6+
namespace:
7+
- "{{data_stream.namespace}}"
8+
- default

0 commit comments

Comments
 (0)