<6> nginx web server 에서 수집하고자 한다. 1 https://artifacthub.io/packages/helm/bitnami/nginx 2 # 모니터링 watch -d kubectl get pod # 파라미터 파일 생성 : 서비스 모니터 방식으로 nginx 모니터링 대상을 등록하고, export 는 9113 포트 사용, nginx 웹서버 노출은 AWS CLB 기본 사용 cat < ~/nginx_metric-values.yaml metrics: enabled: true service: port: 9113 serviceMonitor: enabled: true namespace: monitoring interval: 10s EOT # 배포 helm upgrade nginx bitnami/nginx --reuse-values -f nginx_metric-values.yaml echo "NGINX URL: http://nginx.masterseo1.link" # 확인 kubectl get pod,svc,ep kubectl get servicemonitor -n monitoring nginx kubectl get servicemonitor -n monitoring nginx -o json | jq 3 # 메트릭 확인 >> 프로메테우스에서 Target 확인 NGINXIP=$(kubectl get pod -l app.kubernetes.io/instance=nginx -o jsonpath={.items[0].status.podIP}) curl -s http://$NGINXIP:9113/metrics # nginx_connections_active Y 값 확인해보기 curl -s http://$NGINXIP:9113/metrics | grep ^nginx_connections_active (masterseo1:kube-system) [root@myeks-bastion-EC2 ~]# curl -s http://$NGINXIP:9113/metrics | grep ^nginx_connections_active nginx_connections_active 1 # nginx 파드내에 컨테이너 갯수 확인 kubectl get pod -l app.kubernetes.io/instance=nginx kubectl describe pod -l app.kubernetes.io/instance=nginx (masterseo1:kube-system) [root@myeks-bastion-EC2 ~]# kubectl get pod -l app.kubernetes.io/instance=nginx NAME READY STATUS RESTARTS AGE nginx-85fc957979-4zv5h 2/2 Running 0 53s # 접속 주소 확인 및 접속 echo -e "Nginx WebServer URL = https://nginx.$MyDomain" curl -s https://nginx.$MyDomainkubectl logs deploy/nginx -f # 반복 접속 while true; do curl -s https://nginx.$MyDomain -I | head -n 1; date; sleep 1; done 4 NGINX 애플리케이션 모니터링 대시보드 추가 그라파나에 12708 대시보드 추가