istio 以某种方式覆盖 envoy 的默认访问日志格式

问题描述 投票:0回答:1

正如this详细答案中很好地解释的那样,您可以在

istio
中自定义
IstioOperator
的日志格式。

就我而言,

IstioOperator
(当涉及到访问日志配置时)看起来像这样

    meshConfig:
      accessLogEncoding: JSON
      accessLogFile: /dev/stdout

即未指定

accessLogFormat

但是,在

StackDriver
中,当查看我的
istio-proxy
日志时,我看到一些字段NOT在默认格式中定义。,例如这是相应的
istio-proxy
日志条目

response_code: "200"
bytes_received: "0"
upstream_cluster: "outbound|80||myscv.default.svc.cluster.local"
downstream_remote_address: "10.17.37.1:57362"
upstream_transport_failure_reason: "-"
user_agent: "Mozilla/5.0 (compatible; Cloudflare-Traffic-Manager/1.0; +https://www.cloudflare.com/traffic-manager/; pool-id: 8474894722kdjfhg49)"
duration: "2"
x_forwarded_for: "10.15.22.1"
route_name: "-"
path: "/health"
requested_server_name: "my.public.url.net"
upstream_host: "10.15.37.29:20000"
downstream_local_address: "10.17.37.16:8443"
protocol: "HTTP/1.1"
request_id: "32455-452d-9a7a-9310-71e098fb490R"
start_time: "2021-01-20T17:27:13.021Z"
authority: "my.public.url.net"
istio_policy_status: "-"
upstream_service_time: "2"
bytes_sent: "2"
upstream_local_address: "10.43.37.16:55496"
method: "GET"
response_flags: "-"

我可以看到例如

istio_policy_status
downstream_local_address
(也许还有更多),它们不属于默认格式。

istio
在哪里覆盖
envoy
的默认访问日志格式?

logging istio envoyproxy access-log
1个回答
0
投票

使用 istioctl (ISTIO_VERSION =1.20.3) 时,以下命令对我有用:

istioctl install --set profile=default -y --set meshConfig.accessLogFile=/dev/stdout --set meshConfig.accessLogFormat="{\"protocol\":\"%PROTOCOL%\",\"upstream_service_time\":\"%REQ(x-envoy-upstream-service-time)%\",\"upstream_local_address\":\"%UPSTREAM_LOCAL_ADDRESS%\",\"upstream_remote_address\":\"%UPSTREAM_REMOTE_ADDRESS%\",\"duration\":\"%DURATION%\",\"request_duration\":\"%REQUEST_DURATION%\",\"request_tx_duration\":\"%REQUEST_TX_DURATION%\",\"response_tx_duration\":\"%RESPONSE_TX_DURATION%\",\"response_duration\":\"%RESPONSE_DURATION%\",\"roundtrip_duration\":\"%ROUNDTRIP_DURATION%\",\"upstream_transport_failure_reason\":\"%UPSTREAM_TRANSPORT_FAILURE_REASON%\",\"route_name\":\"%ROUTE_NAME%\",\"downstream_local_address\":\"%DOWNSTREAM_LOCAL_ADDRESS%\",\"user_agent\":\"%REQ(USER-AGENT)%\",\"response_code\":\"%RESPONSE_CODE%\",\"response_flags\":\"%RESPONSE_FLAGS%\",\"start_time\":\"%START_TIME%\",\"method\":\"%REQ(:METHOD)%\",\"request_id\":\"%REQ(X-REQUEST-ID)%\",\"upstream_host\":\"%UPSTREAM_HOST%\",\"x_forwarded_for\":\"%REQ(X-FORWARDED-FOR)%\",\"client_ip\":\"%REQ(True-Client-Ip)%\",\"requested_server_name\":\"%REQUESTED_SERVER_NAME%\",\"bytes_received\":\"%BYTES_RECEIVED%\",\"bytes_sent\":\"%BYTES_SENT%\",\"upstream_cluster\":\"%UPSTREAM_CLUSTER%\",\"downstream_remote_address\":\"%DOWNSTREAM_REMOTE_ADDRESS%\",\"authority\":\"%REQ(:AUTHORITY)%\",\"path\":\"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%\",\"response_code_details\":\"%RESPONSE_CODE_DETAILS%\"}"
--set meshConfig.enableEnvoyAccessLogService=true --set meshConfig.accessLogEncoding=JSON
© www.soinside.com 2019 - 2024. All rights reserved.