Infrastructure/Kubenetes

K8S 환경에서 Container monitoring하기 ( cAdvisor + Prometheus + Grafana )

rajent 2020. 11. 18. 18:24
728x90

개념에 대해서는 알만한 사람은 다아시는 조대협님 블로그를 참고했고요. 그외 참고한 블로그 링크를 남깁니다.
https://bcho.tistory.com/1270

 

쿠버네티스 #14 - 모니터링 (2/3) Prometheus

쿠버네티스 #14 모니터링 2/3 Prometheus를 이용한 모니터링 조대협 (http://bcho.tistory.com) 프로메테우스 그동안 주요 모니터링 솔루션으로 사용되던 힙스터는 1.13 버전 이후로 deprecated 될 예정이고, 그.

bcho.tistory.com

https://imbang.net/2019/06/21/cadvisor-prometheus-grafana-%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EC%BB%A8%ED%85%8C%EC%9D%B4%EB%84%88-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81/

 

CAdvisor + Prometheus + Grafana 를 이용한 컨테이너 모니터링 – imbang.net

도커 호스트 서버의 모니터링은 기존 상용 모니터링 툴에서 제공하는 모니터링으로도 충분히 모니터링이 가능 했다. 하지만 호스트 서버의 각 컨테이너들이 사용하는 리소스를 모니터링 할 수

imbang.net

https://waspro.tistory.com/569

 

[Monitoring] Prometheus & Grafana를 활용한 자원 사용률 모니터링

본 포스팅에서는 Prometheus와 Grafana를 활용한 자원 사용률 모니터링 방법에 대해 알아보겠습니다. 시스템을 구축하고 운영할 때 시스템을 구성하는 요소들의 조화로운 설계도 중요하지만, 모니터

waspro.tistory.com

-cAdvioser설치
sudo docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=8080:8080 --detach=true --name=cadvisor google/cadvisor:latest

- Node-Exporter설치
sudo docker run -d --name node-exporter -p 9100:9100 --restart=unless-stopped prom/node-exporter:v0.14.0

- Prometheus 구성
- 설정파일 작성
## prometheus-cadvisor.yml

scrape_configs:

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.

  - job_name: cadvisor

    # Override the global default and scrape targets from this job every 5 seconds.

    scrape_interval: 5s

    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

    static_configs:

      - targets: [

        'cadvisor:8080',

        'node-exporter:9100'

      ]

- 컨테이너 생성
sudo docker run -d --name prometheus-cadvisor -h prometheus-cadvisor -p 9090:9090 --link cadvisor:cadvisor --link node-exporter:node-exporter -v $(pwd)/prometheus-cadvisor.yml:/etc/prometheus/prometheus.yml prom/prometheus:v1.7.0 -config.file=/etc/prometheus/prometheus.yml

- Grafana 구성 및 연동
- 컨테이너 생성
sudo docker run -d --name grafana -h grafana -e GF_SECURITY_ADMIN_PASSWORD=platform -p 3000:3000 --link prometheus-cadvisor:prometheus-cadvisor grafana/grafana:4.4.3