EKS 안에 프로메테우스, 그라파나를 구성하여 사용하고 있습니다. 

 

기본적으로 pod의 메트릭은 수집되고 있지만 그 외 EC2의 메트릭은 수집되고 있지 않았습니다.

 

Node exporter 를 EC2에 구성 후 프로메테우스 설정 (job)에 등록하여 배포 (수동)으로 진행 중 

 

ec2_sd_configs 라는 것을 알게되어 구성해보았습니다. 

 

 

1. 프로메테우스 pod 에 AmazonEC2ReadOnlyAccess 권한을 부여하였습니다.

https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/associate-service-account-role.html

 

IAM 역할을 수임하도록 Kubernetes 서비스 계정 구성 - Amazon EKS

역할 또는 서비스 계정이 이미 있는 경우 이전 명령이 실패할 수 있습니다. eksctl에는 이러한 상황에서 제공할 수 있는 다양한 옵션이 있습니다. 자세한 내용을 알아보려면 eksctl create iamserviceaccou

docs.aws.amazon.com

 

 

2. 프로메테우스 헬름 설정 추가

 

설정을 설명하면

 

prometheus-ec2-role 는 위에 1번에서 생성한 SA를 입력해주면 됩니다. ( ec2 tag 확인 및 메타데이터 확인 용도)

 

ec2_exporter 는 메트릭 수집 대상을 인식하기 위한 설정 및 라벨 수정에 사용됩니다.

 

serviceAccounts:
  server:
    create: false
    name: "prometheus-ec2-role"
    
    
 - job_name: ec2_exporter
    relabel_configs:
      - source_labels: [__meta_ec2_tag_Name]
        target_label: instance
      - source_labels: [__meta_ec2_private_ip]
        target_label: ip
    ec2_sd_configs:
      - region: ap-northeast-2
        port: 9100
        filters: 
          - name: tag:prometheus
            values: 
              - prometheus

 

 

기존 프로세스 

- ec2 node expoter 설치 -> 프로메테우스 설정 수정 -> 배포 -> 그라파나 확인 

 

변경 프로세스

- ec2 node expoter 설치 -> ec2 Tag 설정 -> 그라파나 확인

 

 

주의사항: 

- 프로메테우스에서 바로 ec2를 인식하지 않습니다.  (대충 5분에 한번?)

- 잠시 생성되고 삭제되는 서비스가 있으면 eks crontjob를 검토 필요 (사실 잘모르겠습니다 ㅠㅠ)

 

 

 

 

참고 블로그

 

https://koudingspawn.de/prometheus-aws-discovery/

https://prometheus.io/docs/prometheus/2.41/configuration/configuration/

https://blog.bespinglobal.com/post/prometheus-설정-가이드/

'AWS > EKS' 카테고리의 다른 글

무중단 배포 (EKS)  (0) 2024.07.07
alb aws-load-balancer-controller error  (1) 2023.11.21
EKS 업데이트 참고하면 좋은 tool  (0) 2023.09.19
eks worknode 서브넷 그룹 변경 (비용)  (2) 2023.08.12
fargate + eks 네트워크 이슈  (0) 2023.03.06

+ Recent posts