Created
February 7, 2023 05:56
-
-
Save elee/b90c2aee0b1a7110621e921a709c1683 to your computer and use it in GitHub Desktop.
envoy mysql example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
admin: | |
address: | |
socket_address: | |
protocol: TCP | |
address: 0.0.0.0 | |
port_value: 9901 | |
stats_sinks: | |
- name: envoy.stat_sinks.dog_statsd | |
typed_config: | |
"@type": type.googleapis.com/envoy.config.metrics.v3.DogStatsdSink | |
max_bytes_per_datagram: 8192 | |
prefix: migration_sidecar | |
address: | |
socket_address: | |
address: 127.0.0.1 | |
port_value: 8126 | |
static_resources: | |
listeners: | |
- name: mysql_listener | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
# 3308 is the replica port already | |
port_value: 3309 | |
filter_chains: | |
- filters: | |
- name: envoy.filters.network.mysql_proxy | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.filters.network.mysql_proxy.v3.MySQLProxy | |
stat_prefix: mysql_stat | |
access_log: "/tmp/foo.log" | |
- name: envoy.filters.network.tcp_proxy | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy | |
stat_prefix: mysql_tcp | |
cluster: mysql_master | |
access_log: | |
- name: "envoy.access_loggers.file" | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog | |
path: "/tmp/envoy_mysql_listener.log" | |
log_format: | |
json_format: | |
jelly: '%DYNAMIC_METADATA(envoy.filters.network.mysql_proxy)%' | |
clusters: | |
- name: mysql_master | |
type: STRICT_DNS | |
load_assignment: | |
cluster_name: mysql_master | |
endpoints: | |
- lb_endpoints: | |
- endpoint: | |
address: | |
socket_address: | |
address: 127.0.0.1 | |
port_value: 3306 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run verbosely
$ docker run --network host --mount type=bind,source="$(pwd)"/envoy-mysql-access.yaml,target=/etc/envoy/envoy.yaml,readonly --mount type=bind,source=/tmp,target=/tmp envoyproxy/envoy-contrib:v1.25.0 envoy -c /etc/envoy/envoy.yaml -l trace
Run quietly with
$ docker run --network host --mount type=bind,source="$(pwd)"/envoy-mysql-access.yaml,target=/etc/envoy/envoy.yaml,readonly --mount type=bind,source=/tmp,target=/tmp envoyproxy/envoy-contrib:v1.25.0
I was expecting to see /tmp/envoy_mysql_listener.log to contain the dynamic metadata described in the filter docs: https://www.envoyproxy.io/docs/envoy/latest/configuration/listeners/network_filters/mysql_proxy_filter#dynamic-metadata
But I guess this is not possible given the final filter in the filter chain is
tcp
? https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-dynamic-metadata