Skip to content

Commit 66097b3

Browse files
committed
chore: add full support for NLB log
Signed-off-by: Kavindu Dodanduwa <[email protected]>
1 parent 5aa2746 commit 66097b3

File tree

6 files changed

+188
-42
lines changed

6 files changed

+188
-42
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: extension/encoding
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add more fields to AWS NLB logs at ELB extension
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [43757]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

extension/encoding/awslogsencodingextension/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -403,30 +403,30 @@ ELB access log record fields are mapped this way in the resulting OpenTelemetry
403403

404404
> AWS Fields are according to [documentation](https://docs.aws.amazon.com/elasticloadbalancing/latest//network/load-balancer-access-logs.html#access-log-entry-format).
405405

406-
| **AWS Field** | **OpenTelemetry Field(s)** |
407-
|------------------------------|-------------------------------------------------------------|
408-
| type | `network.protocol.name` |
409-
| version | `network.protocol.version` |
410-
| time | Log timestamp |
411-
| elb | `cloud.resource_id` |
412-
| listener | `aws.elb.tls.listener.resource_id` |
413-
| client:port | `client.address`, `client.port` |
414-
| destination:port | `destination.address`, `destination.port` |
415-
| received_bytes | `http.request.size` |
416-
| sent_bytes | `http.response.size` |
417-
| tls_cipher | `tls.cipher` |
418-
| tls_protocol_version | `tls.protocol.version` |
419-
| domain_name | `url.domain` |
420-
| connection_time | _Currently not supported_ |
421-
| tls_handshake_time | _Currently not supported_ |
422-
| incoming_tls_alert | _Currently not supported_ |
423-
| chosen_cert_arn | _Currently not supported_ |
424-
| chosen_cert_serial | _Currently not supported_ |
425-
| tls_named_group | _Currently not supported_ |
426-
| alpn_fe_protocol | _Currently not supported_ |
427-
| alpn_be_protocol | _Currently not supported_ |
428-
| alpn_client_preference_list | _Currently not supported_ |
429-
| tls_connection_creation_time | _Currently not supported_ |
406+
| **AWS Field** | **OpenTelemetry Field(s)** |
407+
|------------------------------|-------------------------------------------|
408+
| type | `network.protocol.name` |
409+
| version | `network.protocol.version` |
410+
| time | Log timestamp |
411+
| elb | `cloud.resource_id` |
412+
| listener | `aws.elb.tls.listener.resource_id` |
413+
| client:port | `client.address`, `client.port` |
414+
| destination:port | `destination.address`, `destination.port` |
415+
| received_bytes | `http.request.size` |
416+
| sent_bytes | `http.response.size` |
417+
| tls_cipher | `tls.cipher` |
418+
| tls_protocol_version | `tls.protocol.version` |
419+
| domain_name | `url.domain` |
420+
| connection_time | `aws.elb.connection_time` |
421+
| tls_handshake_time | `aws.elb.tls_handshake_time` |
422+
| incoming_tls_alert | `aws.elb.incoming_tls_alert` |
423+
| chosen_cert_arn | `aws.elb.chosen_cert_arn` |
424+
| chosen_cert_serial | `aws.elb.chosen_cert_serial` |
425+
| tls_named_group | `aws.elb.tls_named_group` |
426+
| alpn_fe_protocol | `aws.elb.alpn_fe_protocol` |
427+
| alpn_be_protocol | `aws.elb.alpn_be_protocol` |
428+
| alpn_client_preference_list | `aws.elb.alpn_client_preference_list` |
429+
| tls_connection_creation_time | `aws.elb.tls_connection_creation_time` |
430430

431431
#### Classic Load Balancer (CLB)
432432

extension/encoding/awslogsencodingextension/internal/unmarshaler/elb-access-log/fields.go

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,31 @@
44
package elbaccesslogs // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/awslogsencodingextension/internal/unmarshaler/elb-access-log"
55

66
const (
7-
AttributeELBStatusCode = "aws.elb.status.code" // int
8-
AttributeELBBackendStatusCode = "aws.elb.backend.status.code" // int
9-
AttributeTLSListenerResourceID = "aws.elb.tls.listener.resource_id" // string
10-
AttributeELBRequestProcessingTime = "aws.elb.request_processing_time" // float
11-
AttributeELBResponseProcessingTime = "aws.elb.response_processing_time" // float
12-
AttributeELBTargetProcessingTime = "aws.elb.target_processing_time" // float
13-
AttributeELBTargetGroupARN = "aws.elb.target_group_arn" // string
14-
AttributeELBChosenCertARN = "aws.elb.chosen_cert_arn" // string
15-
AttributeELBActionsExecuted = "aws.elb.actions_executed" // string
16-
AttributeELBRedirectURL = "aws.elb.redirect_url" // string
17-
AttributeELBErrorReason = "aws.elb.error_reason" // string
18-
AttributeELBClassification = "aws.elb.classification" // string
19-
AttributeELBClassificationReason = "aws.elb.classification_reason" // string
20-
AttributeELBConnectionTraceID = "aws.elb.connection_trace_id" // string
21-
AttributeELBTransformedHost = "aws.elb.transformed_host" // string
22-
AttributeELBTransformedURI = "aws.elb.transformed_uri" // string
23-
AttributeELBRequestTransformStatus = "aws.elb.request_transform_status" // string
24-
AttributeELBAWSTraceID = "aws.elb.aws_trace_id" // string
7+
AttributeELBStatusCode = "aws.elb.status.code" // int
8+
AttributeELBBackendStatusCode = "aws.elb.backend.status.code" // int
9+
AttributeTLSListenerResourceID = "aws.elb.tls.listener.resource_id" // string
10+
AttributeELBRequestProcessingTime = "aws.elb.request_processing_time" // float
11+
AttributeELBResponseProcessingTime = "aws.elb.response_processing_time" // float
12+
AttributeELBTargetProcessingTime = "aws.elb.target_processing_time" // float
13+
AttributeELBTargetGroupARN = "aws.elb.target_group_arn" // string
14+
AttributeELBChosenCertARN = "aws.elb.chosen_cert_arn" // string
15+
AttributeELBActionsExecuted = "aws.elb.actions_executed" // string
16+
AttributeELBRedirectURL = "aws.elb.redirect_url" // string
17+
AttributeELBErrorReason = "aws.elb.error_reason" // string
18+
AttributeELBClassification = "aws.elb.classification" // string
19+
AttributeELBClassificationReason = "aws.elb.classification_reason" // string
20+
AttributeELBConnectionTraceID = "aws.elb.connection_trace_id" // string
21+
AttributeELBTransformedHost = "aws.elb.transformed_host" // string
22+
AttributeELBTransformedURI = "aws.elb.transformed_uri" // string
23+
AttributeELBRequestTransformStatus = "aws.elb.request_transform_status" // string
24+
AttributeELBAWSTraceID = "aws.elb.aws_trace_id" // string
25+
AttributeELBConnectionTime = "aws.elb.connection_time" // int64
26+
AttributeELBTLSNamedGroup = "aws.elb.tls_named_group" // string
27+
AttributeELBTLSHandshakeTime = "aws.elb.tls_handshake_time" // int64
28+
AttributeELBTLSConnectionCreationTime = "aws.elb.tls_connection_creation_time" // int64
29+
AttributeELBIncomingTLSAlert = "aws.elb.incoming_tls_alert" // string
30+
AttributeELBChosenCertSerial = "aws.elb.chosen_cert_serial" // string
31+
AttributeALPNFeProtocol = "aws.elb.alpn_fe_protocol" // string
32+
AttributeALPNBeProtocol = "aws.elb.alpn_be_protocol" // string
33+
AttributeALPNClientPreferenceList = "aws.elb.alpn_client_preference_list" // string
2534
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
tls 2.0 2018-12-20T02:59:40 net/my-network-loadbalancer/c6e77e28c25b2234 g3d4b5e8bb8464cd 72.21.218.154:51341 172.100.100.185:443 5 2 98 246 - arn:aws:acm:us-east-2:671290407336:certificate/2a108f19-aded-46b0-8493-c63eb1ef4a99 - ECDHE-RSA-AES128-SHA tlsv12 - my-network-loadbalancer-c6e77e28c25b2234.elb.us-east-2.amazonaws.com - - - 2018-12-20T02:59:30
12
tls 2.0 2020-04-01T08:51:42 net/my-network-loadbalancer/c6e77e28c25b2234 g3d4b5e8bb8464cd 72.21.218.154:51341 172.100.100.185:443 5 2 98 246 - arn:aws:acm:us-east-2:671290407336:certificate/2a108f19-aded-46b0-8493-c63eb1ef4a99 - ECDHE-RSA-AES128-SHA tlsv12 - my-network-loadbalancer-c6e77e28c25b2234.elb.us-east-2.amazonaws.com h2 h2 "h2","http/1.1" 2020-04-01T08:51:20

extension/encoding/awslogsencodingextension/internal/unmarshaler/elb-access-log/testdata/nlb_al_valid_logs_expected.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,105 @@ resourceLogs:
4343
- key: tls.cipher
4444
value:
4545
stringValue: ECDHE-RSA-AES128-SHA
46+
- key: aws.elb.connection_time
47+
value:
48+
intValue: "5"
49+
- key: aws.elb.tls_handshake_time
50+
value:
51+
intValue: "2"
52+
- key: aws.elb.incoming_tls_alert
53+
value:
54+
stringValue: '-'
55+
- key: aws.elb.tls_named_group
56+
value:
57+
stringValue: '-'
58+
- key: aws.elb.chosen_cert_arn
59+
value:
60+
stringValue: arn:aws:acm:us-east-2:671290407336:certificate/2a108f19-aded-46b0-8493-c63eb1ef4a99
61+
- key: aws.elb.chosen_cert_serial
62+
value:
63+
stringValue: '-'
64+
- key: aws.elb.alpn_fe_protocol
65+
value:
66+
stringValue: '-'
67+
- key: aws.elb.alpn_be_protocol
68+
value:
69+
stringValue: '-'
70+
- key: aws.elb.alpn_client_preference_list
71+
value:
72+
stringValue: '-'
73+
- key: aws.elb.tls_connection_creation_time
74+
value:
75+
stringValue: 2018-12-20T02:59:30
76+
- key: url.domain
77+
value:
78+
stringValue: my-network-loadbalancer-c6e77e28c25b2234.elb.us-east-2.amazonaws.com
79+
body: {}
80+
timeUnixNano: "1545274780000000000"
81+
- attributes:
82+
- key: network.protocol.name
83+
value:
84+
stringValue: tls
85+
- key: network.protocol.version
86+
value:
87+
stringValue: "2.0"
88+
- key: client.address
89+
value:
90+
stringValue: 72.21.218.154
91+
- key: client.port
92+
value:
93+
intValue: "51341"
94+
- key: destination.address
95+
value:
96+
stringValue: 172.100.100.185
97+
- key: destination.port
98+
value:
99+
intValue: "443"
100+
- key: http.request.size
101+
value:
102+
intValue: "98"
103+
- key: http.response.size
104+
value:
105+
intValue: "246"
106+
- key: aws.elb.tls.listener.resource_id
107+
value:
108+
stringValue: g3d4b5e8bb8464cd
109+
- key: tls.protocol.version
110+
value:
111+
stringValue: tlsv12
112+
- key: tls.cipher
113+
value:
114+
stringValue: ECDHE-RSA-AES128-SHA
115+
- key: aws.elb.connection_time
116+
value:
117+
intValue: "5"
118+
- key: aws.elb.tls_handshake_time
119+
value:
120+
intValue: "2"
121+
- key: aws.elb.incoming_tls_alert
122+
value:
123+
stringValue: '-'
124+
- key: aws.elb.tls_named_group
125+
value:
126+
stringValue: '-'
127+
- key: aws.elb.chosen_cert_arn
128+
value:
129+
stringValue: arn:aws:acm:us-east-2:671290407336:certificate/2a108f19-aded-46b0-8493-c63eb1ef4a99
130+
- key: aws.elb.chosen_cert_serial
131+
value:
132+
stringValue: '-'
133+
- key: aws.elb.alpn_fe_protocol
134+
value:
135+
stringValue: h2
136+
- key: aws.elb.alpn_be_protocol
137+
value:
138+
stringValue: h2
139+
- key: aws.elb.alpn_client_preference_list
140+
value:
141+
stringValue: h2
142+
- key: aws.elb.tls_connection_creation_time
143+
value:
144+
stringValue: ',"http/1.1"'
46145
- key: url.domain
47146
value:
48147
stringValue: my-network-loadbalancer-c6e77e28c25b2234.elb.us-east-2.amazonaws.com

extension/encoding/awslogsencodingextension/internal/unmarshaler/elb-access-log/unmarshaler.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ func (f *elbAccessLogUnmarshaler) addToNLBAccessLogs(resourceAttr *resourceAttri
358358
recordLog.Attributes().PutStr(AttributeTLSListenerResourceID, nlbRecord.Listener)
359359
recordLog.Attributes().PutStr(string(conventions.TLSProtocolVersionKey), nlbRecord.TLSProtocolVersion)
360360
recordLog.Attributes().PutStr(string(conventions.TLSCipherKey), nlbRecord.TLSCipher)
361+
recordLog.Attributes().PutInt(AttributeELBConnectionTime, nlbRecord.ConnectionTime)
362+
recordLog.Attributes().PutInt(AttributeELBTLSHandshakeTime, nlbRecord.TLSHandshakeTime)
363+
recordLog.Attributes().PutStr(AttributeELBIncomingTLSAlert, nlbRecord.IncomingTLSAlert)
364+
recordLog.Attributes().PutStr(AttributeELBTLSNamedGroup, nlbRecord.TLSNamedGroup)
365+
recordLog.Attributes().PutStr(AttributeELBChosenCertARN, nlbRecord.ChosenCertARN)
366+
recordLog.Attributes().PutStr(AttributeELBChosenCertSerial, nlbRecord.ChosenCertSerial)
367+
recordLog.Attributes().PutStr(AttributeALPNFeProtocol, nlbRecord.ALPNFeProtocol)
368+
recordLog.Attributes().PutStr(AttributeALPNBeProtocol, nlbRecord.ALPNBeProtocol)
369+
recordLog.Attributes().PutStr(AttributeALPNClientPreferenceList, nlbRecord.ALPNClientPreferenceList)
370+
recordLog.Attributes().PutStr(AttributeELBTLSConnectionCreationTime, nlbRecord.TLSConnectionCreationTime)
361371
if nlbRecord.DomainName != unknownField {
362372
recordLog.Attributes().PutStr(string(conventions.URLDomainKey), nlbRecord.DomainName)
363373
}

0 commit comments

Comments
 (0)