[관측가능성] 프로메테우스로 ArgoCD 메트릭 수집하기

728x90
반응형

프로메테우스 이용하여 ArgoCD 메트릭 수집하기

⚙️ 구현 환경

Amazon EKS 클러스터

 

ArgoCD 메트릭 수집 과정

1. 프로메테우스 설치

1) Prometheus 네임스페이스 생성

kubectl create namespace monitoring

2) Prometheus 설치

monitoring 네임스페이스 안에 프로메테우스 헬름 차트를 이용하여 프로메테우스를 설치한다.

https://github.com/prometheus-community/helm-charts/

 

GitHub - prometheus-community/helm-charts: Prometheus community Helm charts

Prometheus community Helm charts. Contribute to prometheus-community/helm-charts development by creating an account on GitHub.

github.com

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring

 

3) Prometheus 설치 확인

kubectl get pods -n monitoring

 


2. ArgoCD 메트릭스 서비스 모니터 설정

먼저, ArgoCD의 메트릭을 수집하는 서비스의 이름을 확인한다.

kubectl get svc -n argocd

여기에서는 argocd-server-metrics에 해당한다.

 

🟠 argocd-server-metrics 서비스

ArgoCD 서버는 내장된 메트릭 수집기를 통해 /metrics 경로로 메트릭을 제공한다.

argocd-server-metrics 서비스는 ClusterIP 타입으로 내부 네트워크에서 접근할 수 있도록 8083 포트를 통해 Pod으로 연결한다.

  • 역할: ArgoCD 서버에서 노출하는 메트릭을 외부(내부 네트워크)로 노출한다.
  • 메트릭 제공 대상: Prometheus 같은 모니터링 툴이 ArgoCD 서버의 상태를 모니터링할 수 있도록 /metrics 엔드포인트를 제공한다.
  • 주요 설정:
    • ClusterIP 서비스로 내부 클러스터에서만 접근 가능
    • 포트: 8083에서 메트릭을 노출
    • /metrics 경로에서 CPU 사용량, 요청 수, gRPC 호출 통계 등의 지표를 제공한다.

🟠 ServiceMonitor 리소스

ServiceMonitor가 Prometheus Operator에 의해 탐지되면, 해당 엔드포인트(/metrics)가 메트릭 수집 대상으로 등록된다.

  • 역할: Prometheus Operator가 메트릭을 수집할 엔드포인트 정보를 정의한다.
  • 메커니즘:
    • Prometheus Operator는 ServiceMonitor 리소스를 탐색하여 수집할 엔드포인트를 확인한다.
    • ServiceMonitor는 특정 네임스페이스와 서비스 레이블을 기반으로 메트릭을 수집할 서비스를 선택한다.

1) service-monitor.yaml 파일 작성

초기 설정이라 일단 로컬에서 직접 작성하고 적용시키는 방법을 채택했다.
추후 GitOps로 진행하기 위해 GitLab에 업로드하는 방법을 고려하고 있다.

  • 서비스 모니터 이름: argocd-metrics-monitor
  • 네임스페이스: monitoring (프로메테우스가 설치된 네임스페이스)
  • 수집할 메트릭: argocd 네임스페이스 안의 argocd-server-metrics
  • 수집 간격: 30초
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: argocd-metrics-monitor
  namespace: monitoring  # Prometheus가 설치된 네임스페이스
  labels:
    release: prometheus  # Prometheus Helm release 이름과 동일해야 함
spec:
  namespaceSelector:
    matchNames:
      - argocd  # ArgoCD 네임스페이스 지정
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-server-metrics
  endpoints:
    - port: metrics
      path: /metrics
      interval: 30s

 

2) 서비스 모니터 파일 적용

kubectl apply -f argocd-service-monitor.yaml -n monitoring

 

3) argocd-metrics-monitor 서비스 모니터 생성 확인

kubectl get serviceMonitor -n monitoring

 


3.프로메테우스 웹 UI에 접속

다음 명령어로 포트포워딩 실행 후, 웹 브라우저에서 접속해본다.
http://localhost:9090 으로 접속

kubectl port-forward svc/prometheus-kube-prometheus-prometheus -n monitoring 9090:9090

argocd 메트릭 수집 정상 작동

✅ Target health 확인

argocd를 검색했을 때 argocd-metrics-monitoring 이 있는지 확인한다.

State: UP → Prometheus가 정상적으로 메트릭을 수집 중

Configuration 확인

Configuration에서 ArgoCD 메트릭 수집 Job이 등록된 것을 확인할 수 있다.


4. 프로메테우스 서버 로드밸런서로 변경하기

프로메테우스 서버의 서비스 타입 변경

📌 프로메테우스 서버: prometheus-kube-prometheus-prometheus 서비스

✅ ClusterIP → LoadBalancer

spec.type이 원래는 ClusterIP로 되어 있었는데, 이 부분만 LoadBalancer로 변경한다.

kubectl edit svc prometheus-kube-prometheus-prometheus -n monitoring
spec:
  type: LoadBalancer  # ClusterIP → LoadBalancer

i 눌러 수정 → ESC:wq 저장 후 나오기

서비스 타입 변경

 

서비스 확인

서비스 타입을 로드밸런서로 변경하면, 외부에서 접근할 수 있는 EXTERNAL-IP가 할당된다.
http://<EXTERNAL-IP>:9090 또는 http://<ELB DNS>:9090으로 접근하면 Prometheus 대시보드에 접속할 수 있다.

kubectl get svc -n monitoring

이제 직접 포트포워딩하지 않아도, 로드밸런서 주소로 프로메테우스 UI에 접속할 수 있다.

외부 접근 성공!

 

728x90
반응형