-
K8S 환경에서 Container monitoring하기 ( cAdvisor + Prometheus + Grafana )Infrastructure/Kubenetes 2020. 11. 18. 18:24728x90
개념에 대해서는 알만한 사람은 다아시는 조대협님 블로그를 참고했고요. 그외 참고한 블로그 링크를 남깁니다.
https://bcho.tistory.com/1270https://waspro.tistory.com/569
-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.ymlscrape_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