Istio组件日志设置[通俗易懂]

1.istio-pilot日志级别编辑istio-system.deployment.istio-pilot,修改args中–log_output_level=default:指定日志级别2.istio-policy日志级别设置同istio-pilot3.istio-proxy(envoy)日志级别设置进入istio-proxy容器中,通过如下命令进行设置:curl-…

大家好,又见面了,我是你们的朋友全栈君。

1.istio-pilot日志级别

编辑istio-system.deployment.istio-pilot,修改args中–log_output_level=default:指定日志级别

Istio组件日志设置[通俗易懂]

2.istio-policy日志级别设置同istio-pilot

3.istio-proxy(envoy)日志级别设置

进入istio-proxy容器中,通过如下命令进行设置:

curl -X POST localhost:15000/logging?level=trace

4.istio-proxy access日志设置

官方参考:https://istio.io/docs/tasks/telemetry/logs/access-log/

修改istio-system.configMap.istio中的accessLogFile: “/dev/stdout”

Istio组件日志设置[通俗易懂]

修改后即可在istio-proxy看到如下accessLog(业务app pod容器无需重启): 

Istio组件日志设置[通俗易懂]

默认accessLogFormat:

通过如下命令查看accessLogFormat配置:

istioctl proxy-config listeners <your pod> -n <your namespace> -o json

Istio组件日志设置[通俗易懂]

 

[%START_TIME%] \”%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\” %RESPONSE_CODE% %RESPONSE_FLAGS% \”%DYNAMIC_METADATA(istio.mixer:status)%\” %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_SERVER_NAME%\n

实际日志与默认格式对比:

[2019-09-24T05:57:56.836Z] 
“POST /256/vendorRetire/list HTTP/1.1” 
200 – “-” 
113 6029 110 110 
“-” “Apache-HttpClient/4.5.7 (Java/1.8.0_192)” “d17359bf-7b4c-4c44-8dab-003c59fa810b” “s267.tsp” 
“127.0.0.1:8080” inbound|80|http|s267.tsp.svc.cluster.local – 
172.25.193.104:8080 172.25.123.74:33340 – 

====================================================================================

[%START_TIME%] 
\”%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\” 
%RESPONSE_CODE% %RESPONSE_FLAGS% \”%DYNAMIC_METADATA(istio.mixer:status)%\” 
%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_SERVER_NAME%\n

Date 
MPP: method path protocol
RFS: respCode respFlag metadataStaus
RSDR: recvBytes sendBytes duration upStreamServiceTime
FARA: x-forward-for user-agent x-request-id authority
UCL: upstream-host upstream-cluster upstream-local-address
DRS: downstream-localhocal-address downstream-remote-address requested-server-name(sni)
3-3-4-4-3-3

其中RESPONSE_FLAGS定义如下:

Istio组件日志设置[通俗易懂]

envoy log参考:

Envoy官方参考 – access_log#config-access-log-default-format

https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#configuration

stackoverflow – what-is-istio-proxy-access-log-mean 

 

注:Isito 1.7以后最新默认访问日志格式如下:

[%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_SERVER_NAME% %ROUTE_NAME%\n

Istio组件日志设置[通俗易懂]

参考:ISTIO/DOCS/TASKS/OBSERVABILITY/LOGS/Getting Envoy’s Access Logs

其中关于downstream和upstream可参见下图:

Istio组件日志设置[通俗易懂]

5.Springboot Tomcat访问日志

开启如下配置:

server.tomcat.accesslog.enabled = true
server.tomcat.accesslog.directory = /data/logs/tomcat

即可在应用容器中/data/logs/tomcat看到如下访问日志:
Istio组件日志设置[通俗易懂]

查看最近的access_log即可看到tomcat的访问日志:

Istio组件日志设置[通俗易懂]

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/126213.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号