8.9.21. 라우터 지표 노출
기본 통계 포트인 1936에서 Prometheus 형식으로 기본적으로 HAProxy 라우터 지표를 노출할 수 있습니다. Prometheus와 같은 외부 메트릭 컬렉션 및 집계 시스템은 HAProxy 라우터 지표에 액세스할 수 있습니다. 브라우저에서 HAProxy 라우터 메트릭을 HTML 및 쉼표로 구분된 값(CSV) 형식으로 볼 수 있습니다.
사전 요구 사항
- 기본 통계 포트인 1936에 액세스하도록 방화벽을 구성했습니다.
프로세스
다음 명령을 실행하여 라우터 Pod 이름을 가져옵니다.
$ oc get pods -n openshift-ingress출력 예
NAME READY STATUS RESTARTS AGE router-default-76bfffb66c-46qwp 1/1 Running 0 11h라우터 Pod가
/var/lib/haproxy/conf/metrics-auth/statsUsername및/var/lib/haproxy/conf/metrics-auth/statsPassword파일에 저장하는 라우터의 사용자 이름과 암호를 가져옵니다.다음 명령을 실행하여 사용자 이름을 가져옵니다.
$ oc rsh <router_pod_name> cat metrics-auth/statsUsername다음 명령을 실행하여 암호를 가져옵니다.
$ oc rsh <router_pod_name> cat metrics-auth/statsPassword
다음 명령을 실행하여 라우터 IP 및 메트릭 인증서를 가져옵니다.
$ oc describe pod <router_pod>다음 명령을 실행하여 Prometheus 형식으로 원시 통계를 가져옵니다.
$ curl -u <user>:<password> http://<router_IP>:<stats_port>/metrics다음 명령을 실행하여 메트릭에 안전하게 액세스합니다.
$ curl -u user:password https://<router_IP>:<stats_port>/metrics -k다음 명령을 실행하여 기본 stats 포트 1936에 액세스합니다.
$ curl -u <user>:<password> http://<router_IP>:<stats_port>/metrics예 8.1. 출력 예
... # HELP haproxy_backend_connections_total Total number of connections. # TYPE haproxy_backend_connections_total gauge haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route"} 0 haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route-alt"} 0 haproxy_backend_connections_total{backend="http",namespace="default",route="hello-route01"} 0 ... # HELP haproxy_exporter_server_threshold Number of servers tracked and the current threshold value. # TYPE haproxy_exporter_server_threshold gauge haproxy_exporter_server_threshold{type="current"} 11 haproxy_exporter_server_threshold{type="limit"} 500 ... # HELP haproxy_frontend_bytes_in_total Current total of incoming bytes. # TYPE haproxy_frontend_bytes_in_total gauge haproxy_frontend_bytes_in_total{frontend="fe_no_sni"} 0 haproxy_frontend_bytes_in_total{frontend="fe_sni"} 0 haproxy_frontend_bytes_in_total{frontend="public"} 119070 ... # HELP haproxy_server_bytes_in_total Current total of incoming bytes. # TYPE haproxy_server_bytes_in_total gauge haproxy_server_bytes_in_total{namespace="",pod="",route="",server="fe_no_sni",service=""} 0 haproxy_server_bytes_in_total{namespace="",pod="",route="",server="fe_sni",service=""} 0 haproxy_server_bytes_in_total{namespace="default",pod="docker-registry-5-nk5fz",route="docker-registry",server="10.130.0.89:5000",service="docker-registry"} 0 haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="hello-route",server="10.130.0.90:8080",service="hello-svc-1"} 0 ...브라우저에 다음 URL을 입력하여 통계 창을 시작합니다.
http://<user>:<password>@<router_IP>:<stats_port>선택 사항: 브라우저에 다음 URL을 입력하여 CSV 형식으로 통계를 가져옵니다.
http://<user>:<password>@<router_ip>:1936/metrics;csv