ํ์ฌ์์ ๊ทธ๋ผํ๋๋ฅผ ์ฌ์ฉํ์ฌ ์ด์ ์๋ฒ์ ๋ชจ๋ํฐ๋ง์ ํ๊ณ ์๋ค.
node exporter๋ก ์ด์ ์๋ฒ์ ๋ฆฌ์์ค๋ฅผ ๋ชจ๋ํฐ๋ง์ ๋งค์ผ ํ๊ณ ์๋๋ฐ, ๋ฉ๋ชจ๋ฆฌ๋ ๋์คํฌ ์ฌ์ฉ๋์ด ๊ธ์ฆํ์ ๋ ์ค์ ๋ก ์ด๋ค ๋์ปค ์ปจํ ์ด๋๊ฐ ์ํฅ์ ์ฃผ๋์ง ๋ฐ๋ก ์๊ณ ์ถ์๋ค. (ํ์ฌ ๋ชจ๋ ํ๋ก์ธ์ค๊ฐ ๋ค ๋์ปค ์ปจํ ์ด๋๋ก ์คํ๋๊ณ ์๋ค)
์ค์ ๋ก ๊ทธ๋ผํ๋์์ ํ์ธํ๊ธฐ๋ฅผ ๋ฉ๋ชจ๋ฆฌ๊ฐ 10%๊ฐ ์ฆ๊ฐํ๋๋ฐ, ๋๋์ฒด ์ด๋ค ์น๊ตฌ๊ฐ ๋ฉ๋ชจ๋ฆฌ๋ฅผ 10% ๋จน์๊ฑฐ์ผ?! ใ ก.ใ ก ์ถ์ด์ ์๋ฒ ๋ก๊ทธ๋ฅผ sar ๋ฑ ๋ช ๋ น์ด๋ก ๋ค์ ธ๋ด๋ ๋ช ํํ์ง ์์๊ณ ์ ๋ฒ์ฃผ ๋ก๊ทธ๋ ์ฐพ๊ธฐ๋ ์ด๋ ค์ ๋ค ใ ใ ์ด๋ ค์ด ๋๋ฒ๊น .....๐ข
๊ทธ๋์ ์ค์๊ฐ์ผ๋ก ๋์ปค์ ์ฌ์ฉ๋์ ์ ์ฌํ๊ณ ๋ชจ๋ํฐ๋ง ํ๊ณ ์ถ์๋ค...!
์ฐพ์๋ณด๋ ๋์ปค ์ปจํ ์ด๋์ ๋ฉํธ๋ฆญ์ ์ถ์ถํด์ฃผ๋ cadvisor ๋ผ๋ ์ต์คํฌํฐ๊ฐ ์์๊ณ , ๋ฐ๋ก ์ ์ฉํด์ ๊ทธ๋ผํ๋์ ์ฐ๋ํด๋ดค๋ค.
cadvisor ์ปจํ ์ด๋๋ฅผ ๋์ฐ๊ณ ํ๋ก๋ฉํ ์ฐ์ค์ ํ๊ฒ์ ๊ธฐ๋กํ ๋ค์, ๊ทธ๋ผํ๋์ ํด๋น ํ ํ๋ฆฟ์ importํ๊ธฐ๋ง ํ๋ฉด ๋๋ค. ํ๋์ฉ ์ ๋ฆฌํด๋ณด๊ฒ ๋ค.
1. cadvisor ์ปจํ ์ด๋ ๊ธฐ๋
docker run \\
--volume=/:/rootfs:ro \\
--volume=/var/run:/var/run:ro \\
--volume=/sys:/sys:ro \\
--volume=/var/lib/docker/:/var/lib/docker:ro \\
--publish=8080:8080 \\
--detach=true \\
--name=cadvisor \\
google/cadvisor:latest
2. ๊ทธ๋ผํ๋ ์ค์ ํ์ผ์ ํ๊ฒ ์ถ๊ฐ
ํ๋ก๋ฉํ ์ฐ์ค๋ฅผ ๋์ปค๋ก ๋์ ๊ธฐ ๋๋ฌธ์ docker ์ปจํ ์ด๋ ์์ผ๋ก ๋ค์ด๊ฐ์ prometheus.yml์ ํ๊ฒ์ ์๋์ ๊ฐ์ด ์ถ๊ฐํ๊ณ ์ฌ์์ํด์ค๋ค.
docker exec -it prometheus bash
vi /opt/bitnami/prometheus/conf/prometheus.yml
scrape_configs:
- job_name: 'cadvisor'
static_configs:
- targets: ['{์๋ฒ์์ดํผ}:{ํฌํธ}']
docker restart prometheus
์ ์ฒด prometheus.yml ์ฐธ๊ณ
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["192.168.2.54:9090"]
# add10
- job_name: "cadvisor_1"
static_configs:
- targets: ["192.168.2.54:8080"]
# add11
- job_name: "cadvisor_2"
static_configs:
- targets: ["192.168.2.55:8081"]
# add12
- job_name: "cadvisor_3"
static_configs:
- targets: ["192.168.2.53:8080"]
# add13
- job_name: "cadvisor_4"
static_configs:
- targets: ["192.168.2.52:8080"]
# add14
- job_name: "cadvisor_5"
static_configs:
- targets: ["192.168.2.51:8080"]
prometheus UI (http://{ํ๋ก๋ฉํ ์ฐ์คURL}:9090/) ์ ๋ค์ด๊ฐ์ Graph๋ก ๋ค์ด๊ฐ๋ฉด ์๋์ ๊ฐ์ด ๋ฉํธ๋ฆญ์ ํ์ธํ ์ ์๋ค. ๊ฒ์๋ ๊ฐ๋ฅ.
3. ๊ทธ๋ผํ๋ ์ฐ๋
cadvisor exporter ํ ํ๋ฆฟ์ ์๋ ๋์๋ณด๋ ํ ํ๋ฆฟ์ ์ฌ์ฉํ๋ค. ํ ํ๋ฆฟ ID ๋ 14282์ด๊ณ , import ๋ก ์ถ๊ฐํ๋ค.
https://grafana.com/grafana/dashboards/14282-cadvisor-exporter/
Cadvisor exporter | Grafana Labs
Simple set of several graphs. Just for getting Cadvisor’s metrics only Set includes: CPU Usage by containerMemory UsageMemory CachedReceived Network TrafficSent Network Traffic And a table with info: LabelWorking dirServiceRegistry ImageInstanceNameRunni
grafana.com
๋์คํฌ ์ฌ์ฉ๋์ ์์ด์ ์ง์ ๋ฉํธ๋ฆญ์ ์ถ๊ฐํ์ฌ ๋ชจ๋ํฐ๋ง UI๋ฅผ ์์ฑํ๋ค.
WOW..!
์ค์๊ฐ์ผ๋ก ๋์ปค ์ปจํ ์ด๋ ๋ค์ ๋ฆฌ์์ค ์ฌ์ฉ๋์ด ์ค์๊ฐ์ผ๋ก ํ์๋๋ค.
์ด์ ํน์ ์๊ฐ์ ์ด๋ค ์ปจํ ์ด๋๊ฐ ์ด์์ํ์ ์์๋์ง ์์ธ์ ๋น ๋ฅด๊ฒ ํ์ ํ ์ ์์ ๊ฒ ๊ฐ๋ค. (๊ฐ๊ฒฉ๐ญ)
๋๋ฒ๊น ์ด ํ๊ฒฐ ์ฌ์์ง ๊ฒ ๊ฐ๋ค.
๋๋ฃ๋ค๋ ๋๋ฌด ์ข๋ค๋ฉฐ ์ข์ํ๋คใ ใ ใ
Cadvisor exporter ์์ ์ถ์ฒ~~