Istio组件日志设置

1.istio-pilot日志级别

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

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-proxy看到如下accessLog(业务app pod容器无需重启): 

默认accessLogFormat:

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

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

 

[%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定义如下:

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/DOCS/TASKS/OBSERVABILITY/LOGS/Getting Envoy's Access Logs

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

5.Springboot Tomcat访问日志

开启如下配置:

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

即可在应用容器中/data/logs/tomcat看到如下访问日志:

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

  • 2
    点赞
  • 0
    收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:游动-白 设计师:我叫白小胖 返回首页
评论 6

打赏作者

罗小爬EX

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值