Enable json access log format for Kong Ingress Controller

Jbn1233
May 7, 2021

No need config map or config template file. just 2 ENVs can do this

- name: KONG_NGINX_HTTP_LOG_FORMAT
value: x_custom_format escape=json '{"time_local":"$time_local","remote_addr":"$remote_addr","server_addr":"$server_addr","scheme":"$scheme","host":"$host","status":$status,"request_method":"$request_method","uri":"$uri","qu
ery_string":"$query_string","server_protocol":"$server_protocol","bytes_sent":$bytes_sent,"body_bytes_sent":$body_bytes_sent,"request_length":$request_length,"http_referrer":"$http_referer","http_user_agent":"$http_user_agent","requ
est_time":"$request_time","upstream_response_time":"$upstream_response_time","upstream_addr":"$upstream_addr","http_content_type":"$sent_http_content_type","upstream_host":"$upstream_host"}'
- name: KONG_PROXY_ACCESS_LOG
value: logs/access.log x_custom_format

Note: The value must in single line

Done.

--

--

Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |