본문 바로가기

Observability/Prometheus

[Prometheus](GCP)Install Stackdriver-exporter for monitoring GCP with helm chart

Stackdriver?

GCP(Google Cloud Platform) Product를(GCE, GKE, CLOUD SQL 등) 모니터링할 수 있는 Prometheus exporter.

You must have appropriate IAM permissions for this exporter to work. If you are passing in an IAM key then you must have:

  • monitoring.metricDescriptors.list
  • monitoring.timeSeries.list

stackdriver-exporter helm chart
https://artifacthub.io/packages/helm/prometheus-community/prometheus-stackdriver-exporter


Chart download

Helm chart 사용법 참고
2022.05.24 - [Container/Kubernetes] - [Kubernetes]Understand how to use helm chart in Kubernetes

helm fetch prometheus-community/prometheus-stackdriver-exporter

Edit values.yaml

36 service.type: NodePort
45 stackdriver.projectId: "jmhan"
64 stackdriver.metrics.typePrefixes: [수집할 metrics 추가]
  • service.type: exporter를 노출 시킬 서비스 타입을 정한다. NodePort, LoadBalancer 등 원하는 것으로 선택하면 된다.
  • stackdriver.projectId: 모니터링할 GCP projectid를 입력한다.
    • 참고) 해당 프로젝트의 GKE에서 prometheus를 설치하여 모니터링 중
  • stackdriver.metrics.typePrefixes: 수집할 GCP metrics 값을 입력한다.
    • e.g. compute.googleapis.com/instance/cpu/utilization

metircs 추가 - Example

metrics:
    # The prefixes to gather metrics for, we default to just CPU metrics.
    typePrefixes: 
      - 'compute.googleapis.com/instance/cpu/utilization,compute.googleapis.com/instance/cpu/reserved_cores,compute.googleapis.com/instance/memory/balloon/ram_used,compute.googleapis.com/instance/memory/balloon/ram_size,storage.googleapis.com/storage/total_byte_seconds,storage.googleapis.com/storage/total_bytes,kubernetes.io/node/cpu/total_cores,kubernetes.io/node/cpu/allocatable_cores,kubernetes.io/node/memory/total_byte,kubernetes.io/node/memory/used_byte,kubernetes.io/pod/volume/total_bytes,kubernetes.io/pod/volume/utilization,loadbalancing.googleapis.com/https/backend_request_count,https/loadbalancing.googleapis.com/frontend_tcp_rtt'

Google Cloud metrics
https://cloud.google.com/monitoring/api/metrics_gcp

Google Cloud Agent metrics
https://cloud.google.com/monitoring/api/metrics_agent#agent

stackdriver exporter github
https://github.com/prometheus-community/stackdriver_exporter


Install helm chart

helm install stackdriver . -n monitoring
  • prometheus-stackdriver-exporter chart를 배포한 뒤 설정한 서비스타입의 주소로 접속해보면 metrics 값을 확인할 수 있다. (e.g. web browser에서 34.64.151.129.9255/metrics 입력)


설치한 prometheus-stack에 아래 내용 추가한다.

Install prometheus-stack 참고
2022.05.29 - [Monitoring/Prometheus] - [Prometheus]Install prometheus-stack with helm chart

scrape_configs:
      - job_name: prometheus
        static_configs:
          - targets:
            - localhost:9090

- job_name: stackdriver_nodeport
        static_configs:
          - targets:
            - 34.64.151.129.9255
  • stackdriver exporter를 prometheus stack helm chart에 등록하고 chart upgrade를 하면 아래와 같이 prometheus에 데이터가 들어오는 것을 확인할 수 있다.