We use asm-managed-rapid, use ConfigMap to enable access log:
# apiVersion: install.istio.io/v1alpha1
# kind: IstioOperator
# metadata:
# name: istio-ingressgateway
# namespace: istio-system
# spec:
# meshConfig:
# accessLogFile: "/dev/stdout"
# //error: Wating Istio Operator
# apiVersion: telemetry.istio.io/v1alpha1
# kind: Telemetry
# metadata:
# name: istio-ingressgateway
# namespace: istio-system
# spec:
# accessLogging:
# - providers:
# - name: envoy
# format: '{"request": "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%", "response": "%RESPONSE_CODE%", "response_time": "%DURATION%"}'
# outputFormat: '{"request": "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%", "response": "%RESPONSE_CODE%", "response_time": "%DURATION%"}'
# envoy:
# format: '{"request": "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%", "response": "%RESPONSE_CODE%", "response_time": "%DURATION%"}'
# outputFormat: '{"request": "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%", "response": "%RESPONSE_CODE%", "response_time": "%DURATION%"}'
# format: '{"time":"%START_TIME%","method":"%REQ(:METHOD)%","path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","protocol":"%PROTOCOL%","status":%RESPONSE_CODE%,"duration":%DURATION%,"response_size":%RESPONSE_SIZE%,"upstream_host":"%UPSTREAM_HOST%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","user_agent":"%REQ(USER-AGENT)%","request_id":"%REQ(X-REQUEST-ID)%","server_name":"%REQ(:AUTHORITY)%","local_address":"%DOWNSTREAM_LOCAL_ADDRESS%","client_address":"%REQ(X-CLIENT-IPPORT)%","route_name":"%ROUTE_NAME%"}'
# config:
# envoy:
# format: '{"time":"%START_TIME%","method":"%REQ(:METHOD)%","path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","protocol":"%PROTOCOL%","status":%RESPONSE_CODE%,"duration":%DURATION%,"response_size":%RESPONSE_SIZE%,"upstream_host":"%UPSTREAM_HOST%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","user_agent":"%REQ(USER-AGENT)%","request_id":"%REQ(X-REQUEST-ID)%","server_name":"%REQ(:AUTHORITY)%","local_address":"%DOWNSTREAM_LOCAL_ADDRESS%","client_address":"%REQ(X-CLIENT-IPPORT)%","route_name":"%ROUTE_NAME%"}'
# //error: Format does't work
apiVersion: v1
kind: ConfigMap
metadata:
name: istio-asm-managed-rapid
namespace: istio-system
data:
mesh: |-
defaultProviders:
accessLogging:
- stdout
enableEnvoyAccessLogService: true
accessLogFile: /dev/stdout
accessLogEncoding: JSON
accessLogFormat: '{"time":"%START_TIME%","method":"%REQ(:METHOD)%","path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","protocol":"%PROTOCOL%","status":%RESPONSE_CODE%,"duration":%DURATION%,"response_size":%RESPONSE_SIZE%,"upstream_host":"%UPSTREAM_HOST%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","user_agent":"%REQ(USER-AGENT)%","request_id":"%REQ(X-REQUEST-ID)%","server_name":"%REQ(:AUTHORITY)%","local_address":"%DOWNSTREAM_LOCAL_ADDRESS%","client_address":"%REQ(X-CLIENT-IPPORT)%","route_name":"%ROUTE_NAME%"}'
# //error: No log
I’m pretty istio load the config, this is istio bootstrap’s log:
2023-04-20T12:00:22.157556Z info Maximum file descriptors (ulimit -n): 1048576
82
2023-04-20T12:00:22.157889Z info Proxy role ips=[10.185.129.39] type=router id=istio-ingressgateway-946d56bff-mzwzj.asm-ingress domain=asm-ingress.svc.cluster.local
81
2023-04-20T12:00:22.158065Z info Apply mesh config from file defaultProviders:
enableEnvoyAccessLogService: true
accessLogFile: /dev/stdout
accessLogEncoding: JSON
accessLogFormat: '{"time":"%START_TIME%","method":"%REQ(:METHOD)%","path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","protocol":"%PROTOCOL%","status":%RESPONSE_CODE%,"duration":%DURATION%,"response_size":%RESPONSE_SIZE%,"upstream_host":"%UPSTREAM_HOST%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","user_agent":"%REQ(USER-AGENT)%","request_id":"%REQ(X-REQUEST-ID)%","server_name":"%REQ(:AUTHORITY)%","local_address":"%DOWNSTREAM_LOCAL_ADDRESS%","client_address":"%REQ(X-CLIENT-IPPORT)%","route_name":"%ROUTE_NAME%"}'
74
But it does’t work!
When I use Telemetry, it works. But Telemetry does’t support log format.
Please save my life.