Print
카테고리: [ Cloud Computing & MSA ]
조회수: 30439

1. GKE에 prometheus 설치

Helm 3를 사용한 prometheus(stable)를 설치.

설치 후 value.yaml을 살펴보면 아래와 같이 설정된 부분을 볼 수 있다.

- job_name: 'kubernetes-pods'
        kubernetes_sd_configs:
          - role: pod
        relabel_configs:
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
            action: keep
            regex: true
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
            action: replace
            target_label: __metrics_path__
            regex: (.+)
          - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
            action: replace
            regex: ([^:]+)(?::\d+)?;(\d+)
            replacement: $1:$2
            target_label: __address__

2. prometheus monitoring을 위한 설정변경(Deployment)

위 설정을 참고하여 deployment yaml의 template 부분에 아래와 같이 annotation을 추가한다.

template:
    metadata:
      labels:
        app: xxxxapp
      annotations:
              prometheus.io/scrape: 'true'
              prometheus.io/port: 'xxxx'
              prometheus.io/path: '/path/path2/path3'

설정 후 잠시 기다리면 prometheus에서 제대로 deploy 된 pod 모니터링이 되는것을 알 수 있다.