클라우드/쿠버네티스
Spring 프로젝트에서 쿠버네티스 API 사용하기(3) - ec2에서 Grafana 설치 및 Prometheus, Grafana 연동
채야미
2024. 6. 12. 13:36
너무 시간이 오래 흘러서.. 누가 볼지는 모르겠지만
혹시 해메는 사람을 위해 뒤늦게 나마 올려본다
1.Grafana 설치
- Helm 설치 - (이미 설치되어있으므로 생략)
- Grafana Helm 차트를 사용하여 Grafana 설치
helm repo add grafana <https://grafana.github.io/helm-charts> helm repo update helm install grafana grafana/grafana // 로그인 정보를 가져옴 kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
- ClusterIP를 NodePort로 변경 - 포트 번호는 지정하지 않고 조회를 통해 확인할 것
kubectl get svc grafana
spec: type: NodePort // Cluster로 적혀있떤 것을 NodePort로 수정
- 그라파나의 워커노드와 port 번호 확인
얻게된 정보를 합쳐서 웹에서 http://[아이피주소]:[포트 번호] 로 접속가능kubectl get svc grafana -o=jsonpath='{.spec.ports[0].nodePort}' kubectl get nodes -o=jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
초기 로그인 정보 id : admin / password : 2번에서 확인한 로그인 정보아래 화면이 나오면 그라파나 설치 완료
2. Prometheus, Grafana 연동
왼쪽 메뉴중에 Connections을 클릭 Prometheus 선택
url에 프로메테우스 url 입력 하면 완료
Dashboard에서 import를 눌러 새로운 대시보드를 생성
인터넷에서 검색하여 찾은 적절한 대시보드
(https://grafana.com/grafana/dashboards/315-kubernetes-cluster-monitoring-via-prometheus/) 번호를 복사하여 load
아래와 같은 화면이 나오면 성공!