通过Envoy Proxy生成UUID



我正在尝试使用以下特使扩展来关联x-request-id HTTP标头中的uuid

type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfig

这是我的工作yaml,只有一个api是我通过特使暴露的

static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 10001
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: edge
http_filters:
- name: envoy.filters.http.router
route_config:
virtual_hosts:
- name: direct_response_service
domains: ["*"]
routes:
- match:
prefix: "/v1/hello"
route:
cluster: cluster1        
clusters:
- name: cluster1
connect_timeout: 5s
load_assignment:
cluster_name: cluster1
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080

我的问题是在上面的yaml中,我在哪里添加uuid生成的扩展

typed_config:
"@type": type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfig
pack_trace_reason: false

您必须将此扩展放入HttpConnectionManager配置中(在request_id_extension下(:

static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 8080
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
codec_type: AUTO
stat_prefix: ingress_http
request_id_extension:
typed_config:
"@type": type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfig
pack_trace_reason: false
...

我在文档中找到了以下信息:https://www.envoyproxy.io/docs/envoy/v1.21.0/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#extensions-filters-network-http-connection-manager-v3-httpconnection-manager(在页面中搜索request_id_extension(。

此属性在proto文件中定义如下:https://github.com/envoyproxy/envoy/blob/v1.21.0/api/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#L626-L642.

最新更新