
I Tried Saving ELB for Envoy Access Logs to CloudWatch Logs via OTLP
This page has been translated by machine translation. View original
Introduction
On November 25, 2026, the general availability of Elastic Load Balancing for Envoy was announced.
How ELB for Envoy works as a reverse proxy was covered in a previous article.
This article introduces the configuration for saving access logs from Envoy's open_telemetry access logger to CloudWatch Logs.
Test Environment
- Region: Tokyo (ap-northeast-1)
- AWS CLI: 2.42.4
- Proxy version: 1.40
- Request source: working environment (curl)
- Security group: inbound on port 80 allowed from the source IP /32
Preparation
Log Group and Stream
I created the log group /elbproxy-verify/access and the log stream proxy-1 in advance with the following commands. In the configuration file described later, these two names are specified in the x-aws-log-group header and the x-aws-log-stream header.
aws logs create-log-group --log-group-name /elbproxy-verify/access
aws logs create-log-stream --log-group-name /elbproxy-verify/access --log-stream-name proxy-1
Proxy Role Permissions
The proxy role has a statement for process logs described in the ELB for Envoy User Guide. To this, I added the following statement that allows writing to the log group for access logs.
{
"Effect": "Allow",
"Action": ["logs:CreateLogStream", "logs:PutLogEvents"],
"Resource": [
"arn:aws:logs:ap-northeast-1:*:log-group:/elbproxy-verify/access",
"arn:aws:logs:ap-northeast-1:*:log-group:/elbproxy-verify/access:log-stream:*"
]
}
The write permission for the access log group was granted only to the proxy role. The permission to create log groups (logs:CreateLogGroup) was not granted for access logs.
Sending with a Minimal Configuration
I set the destination of the open_telemetry access logger to the CloudWatch Logs OTLP endpoint (/v1/logs). The requests sent were signed with SigV4.
Configuration File
I passed the following config-01-access-log-sigv4.yaml when creating the proxy. It is a configuration that simply returns a fixed response on port 80. The access_log defines the destination and the body format, and the cwl_otlp cluster defines the connection to CloudWatch Logs.
admin:
address:
socket_address:
address: 127.0.0.1
port_value: 9901
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
access_log:
- name: envoy.access_loggers.open_telemetry
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.open_telemetry.v3.OpenTelemetryAccessLogConfig
http_service:
http_uri:
uri: https://logs.ap-northeast-1.amazonaws.com/v1/logs
cluster: cwl_otlp
timeout: 5s
request_headers_to_add:
- header:
key: x-aws-log-group
value: /elbproxy-verify/access
- header:
key: x-aws-log-stream
value: proxy-1
body:
string_value: '%REQ(:METHOD)% %REQ(:PATH)% %PROTOCOL% %RESPONSE_CODE%'
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/"
direct_response:
status: 200
body:
inline_string: "Your proxy is running\n"
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: cwl_otlp
type: STRICT_DNS
dns_lookup_family: V4_ONLY
connect_timeout: 5s
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http_protocol_options: {}
http_filters:
- name: envoy.filters.http.aws_request_signing
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.aws_request_signing.v3.AwsRequestSigning
service_name: logs
region: ap-northeast-1
- name: envoy.filters.http.upstream_codec
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.upstream_codec.v3.UpstreamCodec
load_assignment:
cluster_name: cwl_otlp
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: logs.ap-northeast-1.amazonaws.com
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: logs.ap-northeast-1.amazonaws.com
common_tls_context:
validation_context:
system_root_certs: {}
The signature is added by aws_request_signing placed in the upstream HTTP filter of the cwl_otlp cluster. Only two items, service_name and region, were written for this filter.
Credentials Used for Signing
The credentials used for signing were obtained by the credentials file provider (CredentialsFileCredentialsProvider). I set the proxy attribute envoy.component_log_level to aws:debug,http:info and checked this in the process logs (log group /aws/elb-proxy/<proxy name>).
[2026-11-26 13:36:08.129][2551][debug][aws] [external/envoy+/source/extensions/common/aws/credential_providers/environment_credentials_provider.cc:9] Getting AWS credentials from the environment
[2026-11-26 13:36:08.129][2551][debug][aws] [external/envoy+/source/extensions/common/aws/credentials_provider.cc:41] Provider EnvironmentCredentialsProvider has blank credentials, continuing through chain
[2026-11-26 13:36:08.129][2551][debug][aws] [external/envoy+/source/extensions/common/aws/credential_providers/credentials_file_credentials_provider.cc:47] Getting AWS credentials from the credentials file
[2026-11-26 13:36:08.129][2551][debug][aws] [external/envoy+/source/extensions/common/aws/credential_providers/credentials_file_credentials_provider.cc:72] Credentials file path = <config datasource>, profile name = default
[2026-11-26 13:36:08.129][2551][debug][aws] [external/envoy+/source/extensions/common/aws/credential_providers/credentials_file_credentials_provider.cc:101] Found following AWS credentials for profile 'default': AWS_ACCESS_KEY_ID=<ACCESS-KEY-ID>, AWS_SECRET_ACCESS_KEY=*****, AWS_SESSION_TOKEN=*****
[2026-11-26 13:36:08.129][2551][debug][aws] [external/envoy+/source/extensions/common/aws/credentials_provider.cc:37] Provider CredentialsFileCredentialsProvider has credentials
This log is from after updating to config-02 (the configuration with more saved items).
In the process logs with aws:debug specified, the content of the request to be signed (Canonical request) was output, including the value of x-amz-security-token.
Logs That Arrived in CloudWatch Logs
I sent three requests with curl to the fixed-response /hello, with queries n=1 through n=3. The command for the first request is as follows.
curl -s -i --max-time 10 -A verify-curl/1 http://<PROXY-DNS-NAME>/hello\?n=1
I retrieved the events in the log group with filter-log-events.
aws logs filter-log-events --log-group-name /elbproxy-verify/access --output json
This is the first of the retrieved events.
{
"logStreamName": "proxy-1",
"timestamp": 1795700082574,
"message": "{\"resource\":{\"attributes\":{\"log_name\":\"\",\"zone_name\":\"ap-northeast-1c\",\"cluster_name\":\"verify-access\",\"node_name\":\"<ENI-ID>\"}},\"timeUnixNano\":1795700082574191000,\"observedTimeUnixNano\":0,\"severityNumber\":0,\"severityText\":\"\",\"body\":\"GET /hello?n=1 HTTP/1.1 200\",\"traceId\":\"\",\"spanId\":\"\"}",
"ingestionTime": 1795700083069
}
The three requests were saved as three events. The message is a JSON string, and the body contains the expanded result of the format specified in the access_log body. In resource.attributes, log_name (an empty string in config-01), zone_name, cluster_name (the proxy name), and node_name (the ENI ID) are included even if not written in the configuration. The event's timestamp is the timeUnixNano in the message converted to milliseconds.
Specifying the Items to Save
By writing command operators in the access_log attributes and body, you can choose the items to save. The contents specified in config-02 are as follows.
| Setting | Specified content |
|---|---|
| attributes | 17 items of pairs of key names and command operators |
| body | A format with command operators lined up |
| log_name | access |
| resource_attributes | service.name: elb-for-envoy-verify |
| route and cluster | A route that forwards /ip to checkip.amazonaws.com and a checkip cluster (to see differences in values depending on the path) |
Configuration
The following is the part of config-02 that includes the settings added to config-01. The access_log is placed directly under the typed_config of HttpConnectionManager.
access_log:
- name: envoy.access_loggers.open_telemetry
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.open_telemetry.v3.OpenTelemetryAccessLogConfig
http_service:
http_uri:
uri: https://logs.ap-northeast-1.amazonaws.com/v1/logs
cluster: cwl_otlp
timeout: 5s
request_headers_to_add:
- header:
key: x-aws-log-group
value: /elbproxy-verify/access
- header:
key: x-aws-log-stream
value: proxy-1
log_name: access
resource_attributes:
values:
- key: service.name
value:
string_value: elb-for-envoy-verify
body:
string_value: '[%START_TIME%] "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"'
attributes:
values:
- key: start_time
value:
string_value: '%START_TIME%'
- key: method
value:
string_value: '%REQ(:METHOD)%'
- key: path
value:
string_value: '%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%'
- key: protocol
value:
string_value: '%PROTOCOL%'
- key: response_code
value:
string_value: '%RESPONSE_CODE%'
- key: response_code_details
value:
string_value: '%RESPONSE_CODE_DETAILS%'
- key: response_flags
value:
string_value: '%RESPONSE_FLAGS%'
- key: bytes_received
value:
string_value: '%BYTES_RECEIVED%'
- key: bytes_sent
value:
string_value: '%BYTES_SENT%'
- key: duration_ms
value:
string_value: '%DURATION%'
- key: upstream_cluster
value:
string_value: '%UPSTREAM_CLUSTER%'
- key: upstream_host
value:
string_value: '%UPSTREAM_HOST%'
- key: user_agent
value:
string_value: '%REQ(USER-AGENT)%'
- key: x_forwarded_for
value:
string_value: '%REQ(X-FORWARDED-FOR)%'
- key: request_id
value:
string_value: '%REQ(X-REQUEST-ID)%'
- key: authority
value:
string_value: '%REQ(:AUTHORITY)%'
- key: downstream_remote_address
value:
string_value: '%DOWNSTREAM_REMOTE_ADDRESS%'
This is the /ip route added at the beginning of routes.
- match:
prefix: "/ip"
route:
cluster: checkip
auto_host_rewrite: true
prefix_rewrite: "/"
This is the checkip cluster added to clusters.
- name: checkip
type: STRICT_DNS
dns_lookup_family: V4_ONLY
connect_timeout: 5s
load_assignment:
cluster_name: checkip
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: checkip.amazonaws.com
port_value: 80
With this configuration file, I updated the configuration of the running proxy.
aws elb-proxy update-proxy-configuration --proxy-identifier <PROXY-ARN> --cli-binary-format raw-in-base64-out --configuration-file configurationBytes@=file://artifacts/config-02-access-log-items.yaml --output json
I checked the completion of the update with get-proxy-update.
aws elb-proxy get-proxy-update --proxy-identifier <PROXY-ARN> --update-identifier <UPDATE-ID> --output json
This time, it took 16.4 seconds from the acceptance of the update (submittedAt) to its completion (completedAt).
Values of the Saved Items
After the update, I sent requests with curl to the fixed-response /direct?x=1 and to /ip, which forwards to checkip.amazonaws.com. The message of the event saved for the request to /ip, formatted, is as follows.
{
"resource": {
"attributes": {
"log_name": "access",
"zone_name": "ap-northeast-1c",
"cluster_name": "verify-access",
"node_name": "<ENI-ID>",
"service.name": "elb-for-envoy-verify"
}
},
"timeUnixNano": 1795700167710754000,
"observedTimeUnixNano": 0,
"severityNumber": 0,
"severityText": "",
"body": "[2026-11-26T13:36:07.710Z] \"GET /ip HTTP/1.1\" 200 - 0 15 137 \"-\" \"verify-curl/forward\" \"8bc296d3-43a0-48f0-bd5a-4143018c8ea3\" \"checkip.amazonaws.com\" \"<UPSTREAM-IP>:80\"",
"attributes": {
"start_time": "2026-11-26T13:36:07.710Z",
"method": "GET",
"path": "/ip",
"protocol": "HTTP/1.1",
"response_code": "200",
"response_code_details": "via_upstream",
"response_flags": "-",
"bytes_received": "0",
"bytes_sent": "15",
"duration_ms": "137",
"upstream_cluster": "checkip",
"upstream_host": "<UPSTREAM-IP>:80",
"user_agent": "verify-curl/forward",
"x_forwarded_for": "-",
"request_id": "8bc296d3-43a0-48f0-bd5a-4143018c8ea3",
"authority": "checkip.amazonaws.com",
"downstream_remote_address": "<SOURCE-IP>:4991"
},
"traceId": "",
"spanId": ""
}
Compared with the event for the fixed response (/direct?x=1), the items whose values change depending on the path are as follows.
| Item | Fixed response /direct?x=1 | Forwarded /ip |
|---|---|---|
| response_code_details | direct_response | via_upstream |
| bytes_sent | 22 | 15 |
| duration_ms | 0 | 137 |
| upstream_cluster | - | checkip |
| upstream_host | - | <UPSTREAM-IP>:80 |
| authority | <PROXY-DNS-NAME> |
checkip.amazonaws.com |
For path, I specified %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%. Even in the event for /ip, which was forwarded after being rewritten to / by prefix_rewrite, path contained the pre-rewrite /ip. In the event for the forwarding with auto_host_rewrite set, authority contained the host name of the forwarding destination.
Summary
From the open_telemetry access logger of ELB for Envoy, I sent access logs with a SigV4 signature to the OTLP endpoint of CloudWatch Logs in the Tokyo Region and was able to confirm them in the log group.
According to the User Guide, besides the open_telemetry tried this time, http_grpc, tcp_grpc, and fluentd can be used as network access loggers.
If you have no existing logging platform and want to keep everything within AWS, sending to CloudWatch Logs with the open_telemetry tried this time is the first candidate. If you have a proven existing logging platform and a logger that can send to that platform is supported, I recommend choosing by comparing that logger with open_telemetry, including non-functional requirements.
