<3> 프로메테우스 기본 사용 1 모니터링 대상이 되는 서비스는 일반적으로 자체 웹 서버의 /metrics 엔드포인트 경로에 다양한 메트릭 정보를 노출 2 # 아래 처럼 프로메테우스가 각 서비스의 9100 접속하여 메트릭 정보를 수집 kubectl get node -owide kubectl get svc,ep -n monitoring kube-prometheus-stack-prometheus-node-exporter # 노드의 9100번의 /metrics 접속 시 다양한 메트릭 정보를 확인할수 있음 : 마스터 이외에 워커노드도 확인 가능 ssh ec2-user@$N1 curl -s localhost:9100/metrics ------------ : # TYPE promhttp_metric_handler_requests_in_flight gauge promhttp_metric_handler_requests_in_flight 1 # HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code. # TYPE promhttp_metric_handler_requests_total counter promhttp_metric_handler_requests_total{code="200"} 20 promhttp_metric_handler_requests_total{code="500"} 0 promhttp_metric_handler_requests_total{code="503"} 0 3 프로메테우스 ingress 도메인으로 웹 접속 # ingress 확인 kubectl get ingress -n monitoring kube-prometheus-stack-prometheus kubectl describe ingress -n monitoring kube-prometheus-stack-prometheus # 프로메테우스 ingress 도메인으로 웹 접속 echo -e "Prometheus Web URL = https://prometheus.$MyDomain" :kube-system) [root@myeks-bastion-EC2 ~]# echo -e "Prometheus Web URL = https://prometheus.$MyDomain" Prometheus Web URL = https://prometheus.masterseo1.link # 웹 상단 주요 메뉴 설명 1. 경고(Alert) : 사전에 정의한 시스템 경고 정책(Prometheus Rules)에 대한 상황 2. 그래프(Graph) : 프로메테우스 자체 검색 언어 PromQL을 이용하여 메트릭 정보를 조회 -> 단순한 그래프 형태 조회 3. 상태(Status) : 경고 메시지 정책(Rules), 모니터링 대상(Targets) 등 다양한 프로메테우스 설정 내역을 확인 > 버전(2.42.0) 4. 도움말(Help) 4 현재 각 Target 클릭 시 메트릭 정보 확인 : 아래 예시 ? # serviceMonitor/monitoring/kube-prometheus-stack-kube-proxy/0 (3/3 up) 중 노드1에 Endpoint 접속 확인 (접속 주소는 실습 환경에 따라 다름) curl -s http://192.168.1.216:10249/metrics | tail -n 5 rest_client_response_size_bytes_bucket{host="006fc3f3f0730a7fb3fdb3181f546281.gr7.ap-northeast-2.eks.amazonaws.com",verb="POST",le="4.194304e+06"} 1 rest_client_response_size_bytes_bucket{host="006fc3f3f0730a7fb3fdb3181f546281.gr7.ap-northeast-2.eks.amazonaws.com",verb="POST",le="1.6777216e+07"} 1 rest_client_response_size_bytes_bucket{host="006fc3f3f0730a7fb3fdb3181f546281.gr7.ap-northeast-2.eks.amazonaws.com",verb="POST",le="+Inf"} 1 rest_client_response_size_bytes_sum{host="006fc3f3f0730a7fb3fdb3181f546281.gr7.ap-northeast-2.eks.amazonaws.com",verb="POST"} 626 rest_client_response_size_bytes_count{host="006fc3f3f0730a7fb3fdb3181f546281.gr7.ap-northeast-2.eks.amazonaws.com",verb="POST"} 1 # serviceMonitor/monitoring/kube-prometheus-stack-api-server/0 (2/2 up) 중 Endpoint 접속 확인 (접속 주소는 실습 환경에 따라 다름) >> 해당 IP주소는 어디인가요?, 왜 apiserver endpoint는 2개뿐인가요? , 아래 메트릭 수집이 되게 하기 위해서는 어떻게 하면 될까요? curl -s https://192.168.1.53/metrics | tail -n 5 ... # 그외 다른 타켓의 Endpoint 로 접속 확인 가능 : 예시) 아래는 coredns 의 Endpoint 주소 (접속 주소는 실습 환경에 따라 다름) curl -s http://192.168.1.75:9153/metrics | tail -n 5 # TYPE process_virtual_memory_bytes gauge process_virtual_memory_bytes 7.79350016e+08 # HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes. # TYPE process_virtual_memory_max_bytes gauge process_virtual_memory_max_bytes 1.8446744073709552e+19 exporter가 준비해준다. 프로메테우스가 가져온다.