ingress-nginx-controller configmap 의 설정으 변경하면 된다. nginx pod 재기동도 필요 없다.

 

1. 기본 로그 출력

20.108.82.216 - - [01/Aug/2026:03:37:10 +0000] "GET /core/hostname HTTP/1.1" 200 26 "-" "curl/7.61.1" 115 0.007 [anotherclass-322-core-3222-80] [] 20.108.82.208:8080 26 0.007 200 d29a6bfd8b8e5154a18ece4f0a92efb0

 

2. 변경

$ kubectl -n ingress-nginx edit cm ingress-nginx-controller

...
data:
  log-format-upstream: '[$time_local] Remote[$remote_addr] $http_user_agent -> Service[$service_name] -> Pod[$upstream_addr] : $request $content_type Sta[$upstream_status] ReqLen[$request_length] ResLen[$upstream_response_length] Dur[$upstream_response_time]'
...

 

3. 확인

[01/Aug/2026:03:38:10 +0000] Remote[20.108.82.216] curl/7.61.1 -> Service[core-3222] -> Pod[20.108.82.208:8080] : GET /core/hostname HTTP/1.1 - Sta[200] ReqLen[115] ResLen[26] Dur[0.011]

 

참고: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/log-format/

 

Log format - Ingress-Nginx Controller

Log format The default configuration uses a custom logging format to add additional information about upstreams, response time and status. log_format upstreaminfo '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_refe

kubernetes.github.io

 

블로그 이미지

망원동똑똑이

프로그래밍 지식을 자유롭게 모아두는 곳입니다.

,