I want to set some metadatas in routes config, and get them in access logs. where I have known the function is .

however, I can't figure out how to write the yaml file, I have tried many times, but it not works.

admin: access_log_path: /tmp/admin_access.log address: socket_address: { address: 0.0.0.0, port_value: 9901 } static_resources: listeners: - name: listener_0 address: socket_address: { address: 0.0.0.0, port_value: 10000 } filter_chains: - filters: - name: envoy.http_connection_manager config: tracing: operation_name: ingress use_remote_address: true add_user_agent: true generate_request_id: true stat_prefix: ingress_http codec_type: AUTO route_config: name: local_route virtual_hosts: - name: local_service domains: ["*"] routes: - match: { prefix: "/trace/1" } route: { cluster: some_serviceA } metadata: filter_metadata: envoy.http_connection_manager.access_log: test: "this is metadata" http_filters: - name: envoy.router access_log: - name: envoy.http_grpc_access_log config: common_config: grpc_service: envoy_grpc: cluster_name: accesslog_cluster log_name: accesslog clusters: - name: some_serviceA connect_timeout: 0.25s lb_policy: ROUND_ROBIN type: STATIC hosts: [{ socket_address: { address: 127.0.0.1, port_value: 5001 }}] - name: accesslog_cluster connect_timeout: 2s hosts: - socket_address: address: 127.0.0.1 port_value: 18090 http2_protocol_options: {} 

But I get nothing from common metadata.

Is there an example to set the metadata into access log?

1

1 Answer

Dynamic Metadata can be set by filters using the StreamInfo API (): setDynamicMetadata.

You can also use Lua to set it:

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.