<aside> 💡

Promethus에서 메트릭이 수집되지 않는 문제를 해결합니다.

</aside>

<aside>

문제의 원인


Prometheus는 현재 다음 엔드포인트로 scrape 하고 있음:

<http://10.42.2.89:9090/metrics>

하지만 Knative Activator 컨테이너는 /metrics를 제공하지 않는다.

✔ Deployment 정의를 보면 metrics 포트 9090이 열려 있지만

✔ 실제 Knative Serving 1.20 버전부터 Activator는 Prometheus metrics endpoint를 기본 제공하지 않는다.

그래서 Prometheus가 매번 실패하는 것.

</aside>

<aside>

왜 /metric 에서 제공하지 않나?


Knative 1.19+, 1.20 버전에서 Observability 구성이 바뀌었고:

config-observability

특히 아래 key가 필요:

metrics.backend-destination: prometheus

지금은 이 값이 비어 있거나, "none"이라서 metrics가 disable 되어 있는 상태이다.

</aside>

<aside>

Knative Activator는 9090 포트를 노출하지 않는다 → 당연히 connection refused

Knative Activator 컨테이너는 기본적으로 다음 두 포트만 노출한다 :

Port 용도
8012 Activator 내부 프로세스 포트
9090 옛 버전에만 사용. 최신 Knative는 이 포트를 metrics로 사용하지 않음
9091 ✔ Prometheus metrics 포트 (기본)
</aside>

해결 GOGO !!

1. Observability ConfigMap에서 metrics 활성화

kubectl edit cm config-observability -n knative-serving

아래와 같이 수정

data:
  metrics.backend-destination: prometheus
  profiling.enable: "true"
  profiling.enable-http2: "true"
kubectl rollout restart deploy -n knative-serving

2. Prometheus가 scrap하는 메트릭 확인

[root@ip-10-0-21-238 ~]# kubectl get svc -n knative-serving -o custom-columns=NAME:.metadata.name,PORT:.spec.ports[*].port,PORT_NAME:.spec.ports[*].name
NAME                         PORT                  PORT_NAME
activator-service            9090,8008,80,81,443   http-metrics,http-profiling,http,http2,https
autoscaler                   9090,8008,8080        http-metrics,http-profiling,http
autoscaler-bucket-00-of-01   8080                  http
autoscaler-hpa               9090,8008             http-metrics,http-profiling
controller                   9090,8008             http-metrics,http-profiling
kourier                      80,443                http2,https
kourier-internal             80,443                http2,https
net-kourier-controller       18000,9090            grpc-xds,http-metrics
webhook                      90