修改 Istio 访问日志格式为 json 输出

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

当输出 accessLogEncoding 设置为 JSON 时,如何修改 istio meshconfig 访问日志格式,按文档中描述的方式更改格式不起作用。 spec: meshConfig: accessLogFile: /dev/stdout accessLogEncoding: JSON accessLogFormat: '[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %RESPONSE_CODE_DETAILS% %CONNECTION_TERMINATION_DETAILS%\"%UPSTREAM_TRANSPORT_FAILURE_REASON%\" %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%\" %UPSTREAM_CLUSTER% %UPSTREAM_LOCAL_ADDRESS% %DOWNSTREAM_LOCAL_ADDRESS% %DOWNSTREAM_REMOTE_ADDRESS% %REQUESTED_SER'


kubernetes istio
2个回答
9
投票

spec: meshConfig: accessLogFile: /dev/stdout accessLogEncoding: JSON accessLogFormat: | { "protocol": "%PROTOCOL%", "upstream_service_time": "%REQ(x-envoy-upstream-service-time)%", "upstream_local_address": "%UPSTREAM_LOCAL_ADDRESS%", "duration": "%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%" }



0
投票

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.