Enable http header logging for envoy in istio Enable http header logging for envoy in istio kubernetes kubernetes

Enable http header logging for envoy in istio


I think I've succesfully made a reproduction of your issue and I was able to print MY_CUSTOM_HEADER in the ingress gateway logs.

There is a part of my istio ingress gateway logs.

[2021-01-20T08:26:18.587Z] pkarambol GET /productpage HTTP/1.1 200

I've used below curl command:

curl -v -H "MY_CUSTOM_HEADER: pkarambol" xx.xxx.xx.xxx/productpage

To make that happen you have to change the default format of the logs. As mentioned in the documentation, you can use meshConfig.accessLogFormat to change that.


There is an example of Istio Operator I've used.

%REQ(MY_CUSTOM_HEADER)% is a part responsible for displaying the custom header.

apiVersion: install.istio.io/v1alpha1kind: IstioOperatormetadata:  namespace: istio-system  name: example-istiocontrolplanespec:  profile: demo  meshConfig:    accessLogFile: /dev/stdout    accessLogFormat: "[%START_TIME%] %REQ(MY_CUSTOM_HEADER)% %REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%%RESPONSE_CODE% %RESPONSE_FLAGS% %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%\n"