gpt4 book ai didi

logging - 在 istio 中为 envoy 启用 http 头日志记录

转载 作者:行者123 更新时间:2023-12-04 12:30:25 25 4
gpt4 key购买 nike

我希望能够捕获(记录)(至少部分)envoy我的 istio 上的 HTTP header 服务网格。
我经历过envoydocs ,并且在日志级别的部分中,它没有提到任何特定于标题的信息。
目前,我的 istio-proxy日志是这样的(这是来自 stern 输出):

mysvc-69c46fbc75-d9v8j istio-proxy {"bytes_sent":"124","upstream_cluster":"inbound|80|http|mysvc.default.svc.cluster.local","downstream_remote_address":"10.11.11.1:0","authority":"some.url.com","path":"/health?source=dd_cluster_agent","protocol":"HTTP/1.1","upstream_service_time":"1","upstream_local_address":"127.0.0.1:40406","duration":"2","upstream_transport_failure_reason":"-","route_name":"default","downstream_local_address":"10.11.32.32:20000","user_agent":"Datadog Agent/7.24.0","response_code":"200","response_flags":"-","start_time":"2021-01-17T18:54:57.449Z","method":"GET","request_id":"61ae63c7-aa10-911b-9562-939kdhd49ddhj","upstream_host":"127.0.0.1:20000","x_forwarded_for":"10.16.32.1","requested_server_name":"outbound_.80_.mysvc_.faros.default.svc.cluster.local","bytes_received":"0","istio_policy_status":"-"}
有没有办法登录 http标题? (理想情况下 一些 ,以控制伐木成本)
编辑1 按照评论中的建议,我检查了我的 istio-operator资源,我看到似乎启用了访问日志记录
    meshConfig:
accessLogEncoding: JSON
accessLogFile: /dev/stdout
编辑2 我还尝试了以下方法:
curl -i -H "Custom-Header: application/json" https://my.url.net
但在 istio-ingressgateway 的日志中我没有看到我的自定义标题
istio-ingressgateway-58f69d8696-rmpwn istio-proxy {"user_agent":"curl/7.64.1","response_code":"200","response_flags":"-","start_time":"2021-01-18T19:02:48.645Z","method":"GET","request_id":"8e32c93c-484d-9c56-9489-8c5392793d97","upstream_host":"10.16.32.55:20000","x_forwarded_for":"10.16.32.1","requested_server_name":"my.url.net","bytes_received":"0","istio_policy_status":"-","bytes_sent":"124","upstream_cluster":"outbound|80||mysvc.default.svc.cluster.local","downstream_remote_address":"10.16.32.1:52804","authority":"my.url.net","path":"/","protocol":"HTTP/2","upstream_service_time":"9","upstream_local_address":"10.16.32.17:49826","duration":"10","upstream_transport_failure_reason":"-","route_name":"-","downstream_local_address":"10.16.32.17:8443"}

最佳答案

我想我已经成功复制了您的问题,并且可以打印 MY_CUSTOM_HEADER在入口网关日志中。
我的 istio 入口网关日志中有一部分。

[2021-01-20T08:26:18.587Z] pkarambol GET /productpage HTTP/1.1 200
我使用了以下 curl 命令:
curl -v -H "MY_CUSTOM_HEADER: pkarambol" xx.xxx.xx.xxx/productpage

要做到这一点,您必须更改 default format的日志。如 documentation 中所述,您可以使用 meshConfig.accessLogFormat改变这一点。

有一个 Istio Operator 的例子我用过。 %REQ(MY_CUSTOM_HEADER)%是负责显示自定义标题的部分。
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
namespace: istio-system
name: example-istiocontrolplane
spec:
profile: demo
meshConfig:
accessLogFile: /dev/stdout
accessLogFormat: "[%START_TIME%] %REQ(MY_CUSTOM_HEADER)% %REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%
%RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION%
%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% %REQ(X-FORWARDED-FOR)% %REQ(USER-AGENT)%
%REQ(X-REQUEST-ID)% %REQ(:AUTHORITY)% %UPSTREAM_HOST%\n"

关于logging - 在 istio 中为 envoy 启用 http 头日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65771496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com