basic
Last updated
Was this helpful?
Last updated
Was this helpful?
source-code :
์๋ฒ๋ ํ๋ก๊ทธ๋จ์ ๋ชจ๋ํฐ๋ง ํ๊ธฐ ์ํด ์ฌ์ฉํ๋ค.
ํน์ง์ pull๋ฐฉ์์ด๋ผ๋๊ฒ. ์ด๊ฒ์ด ์ ์ ํ์
Prometheus ์๋ฒ๊ฐ ๋ ธ๋์ ๋ฐ์ดํฐ๋ฅผ ์์ฒญํ๋ฉด ๋ ธ๋๋ ํ๋ก๊ทธ๋จ๋ฑ์ ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ด์ฃผ๋ฉด ๋๋ค. ๋ ธ๋๋ ์ ํ prometheus ์๋ฒ์ ๋ํด ์ ํ์๊ฐ ์๊ณ ๋ฐ์ดํฐ์ ์ ๋ฌ์ ๋ํด์ ๊ณ ๋ฏผํ์ง ์์๋ ๋๋ค.
push : ๊ฐ๊ฐ ๋ชจ๋ํฐ๋๋ ์๋ฒ์์ ์ฃผ๊ธฐ์ ์ผ๋ก ๋ชจ๋ํฐ๋ง ์๋ฒ๋ก ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ด๋ ๋ฐฉ์
pull : ๊ฐ๊ฐ ๋ชจ๋ํฐ๋๋ ์๋ฒ์์ ๋ฐ๋ชฌ๋ง ๋๊ณ ์๊ณ ๋ชจ๋ํฐ๋ง ์๋ฒ์์ request๋ฅผ ๋์ ์ pullํ๋ ๋ฐฉ์
prometheus : ๋ฐ์ดํฐ๋ฅผ ์์ฒญํ๊ณ ๊ฐ์ ธ์จ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ณ ์ฟผ๋ฆฌํจ
exporter: ์์ฒญ์ ๋ฐ์ผ๋ฉด ๋ฐ์ดํฐ๋ฅผ ๋ง๋ค์ด์ ์์ฒญ์์๊ฒ ๋ฆฌํดํด ์ค๋ค.
push gateway : ๋ฐ๋ชฌํํ๋ก ํ๋ก๊ทธ๋จ์ด ๋ ์๋๊ฒ ์๋๊ณ ๋ฐฐ์นํํ๋ก ์คํ๋๊ณ ์ฌ๋ผ์ง๋ ํ๋ก์ธ์ค๋ pull์ ํ ์๊ฐ ์์ผ๋ฏ๋ก ์ด๊ฑธ ์ด์ฉํด์ prometheus์ ๋ณด๋ด์ค๋ค.
alarm manager : ๋ฐ์ดํฐ๊ฐ ํน์ ์กฐ๊ฑด์ด ๋๋ฉด ์๋ฆผ์ ์๋ ค์ค๋ค. (์ฌ๋ ๋๋ ์ด๋ฉ์ผ ๋ฑ๋ฑ ๋ง๋ค.)
dashboard : ์นํ๋ฉด์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ค๋ค. ๊ธฐ๋ณธ์ ์ธ ํ๋ฉด์ด prometheus๊ฐ ๊ฐ์ง๊ณ ์์ผ๋ Grafana๋ฅผ ๋๋ถ๋ถ ์ฌ์ฉํ๋ค.
prometheus.yml์ ์ค์ ํ๊ณ ๋์ ๋์ปค๋ฅผ ์คํํ์.
์๋น์ค๊ฐ ์คํ๋๋ฉด ๋ก์ปฌ์์ ํ์ธํด๋ณด์

์ด์ ํ์ธํด๋ณด์.
๋ค์๊ทธ๋ฆผ์ฒ๋ผ up์ ๋ฃ๊ณ ์ํฐ๋ฅผ ์ฒ๋ณด๋ฉด

up์ Prometheus๊ฐ ์ถ๊ฐํ๋ ํน๋ณํ ํํ์ ๋ฉํธ๋ฆญ์ด๋ค. 1์ ์ฑ๊ณต์ด๋ผ๋ ์๋ฏธ์ด๋ค.
Node Exporter ์ค์น (linux)
์ด์ ๋ชจ๋ํฐ๋ง ํ ์๋ฒ๋ฅผ ์ค์ ํ์. Prometheus๊ฐ ์์ฒญํ๋ฉด ๋ฐ์ดํฐ๋ฅผ ๋ง๋ค์ด์ ์ค๋ค.
Node Exporter๋ cpu ๋ฉ๋ชจ๋ฆฌ ๋์คํฌ๊ณต๊ฐ ๋์คํฌ i/o ๋คํธ์ํฌ ๋์ญํญ ๊ฐ์ ๋ชจ๋ ํ์ค ๋ฉํธ๋ฆญ์ ์ ๊ณตํ๋ค.
๋ ธ๋ exporter๋ ๋ฐ์ด๋๋ฆฌ๋ก ์ค์น
vi /etc/systemd/system/node_exporter.service
๋ชจ๋ํฐ๋ง ๋นํ๋ ์๋ฒ์ ๋ฉํธ๋ฆญ์ ๊ฐ์ ธ์๋ณด์.
๊ฒฐ๊ณผ๊ฐ ์ญ ๋์จ๋ค node exporter๋ ๋์ํ๋ค. ์ด์ ํ๋ก๋ฉํ ์ฐ์ค๊ฐ ์ฃผ๊ธฐ์ ์ผ๋ก ์ด๊ฑธ ๊ฐ์ ธ์ค๋ฉด๋๋ค.
Prometheus ์ค์ ์ ์ถ๊ฐํ์.
Prometheus ํ๊ฒ์ ์ถ๊ฐ๊ฐ ๋๊ฑด์ง ํ์ธํ์.
node01์์ ์ฌ๋ถํ ํด๋ณด์ ์๋น์ค๋ง ๊บผ๋ ๋จ.
์ด์ http://localhost:9090/graph ์์ up์ ํ์ธํด๋ณด์ ๋ด๋ ค๊ฐ๋ค๊ฐ ์ฌ๋ผ์จ๊ฒ์ ํ์ธํ ์ ์๋ค.

Prometheus ์ ๋์ํ๊ณ node exporter๋ ์ ๋์ํ๋๊ฒ์ ์์๊ฐ ์๋ค.
์ด์ docker-compose๋ก ๋ง๋ค์ด์๋ณด์.
https://github.com/martinlindhe/wmi_exporter
https://grafana.com/grafana/dashboards/2129 theme
https://github.com/martinlindhe/wmi_exporter/releases ๋ค์ดํ ์ค์นํ๋ฉด ์๋น์ค๋ก ์ค์น ์๋ฃ

msi downloadํ ๋ ธ๋์ ์ค์น
์ค์น ๋ ธ๋์์ ๋ค์ ํ์ธ
์ธ๋ถ์์ ๋ค์ ํ ์คํธ
Prometheus์ ์ถ๊ฐํ์ฌ ๋ถ์ด์. 9182 ํฌํธ๋ฅผ ์ด๋ค.
vi prometheus.yml
์ด๋ ๊ฒ ํ๋ฉด ์๋์ฐ๋ ๋ชจ๋ํฐ๋ง์ด ๋๋ค.
node export node01์๊บผ๋ณด์.
ssh node01 systemctl stop node_exporter
http://localhost:9090/targets ์์ ์ฒดํฌํด๋ณด๋ฉด ๊บผ์ง๊ฒ์ ์์ ์๋ค.
๊ทธ๋ํ์์ up == 0 ์ ๋ฃ์ด์ ๊บผ์ง๊ฒ๋ง ํ์ธํด๋ณด์.
1๊ฐ๋ง ๋์จ๋ค.

์ด์ ๋ค ๋๋ฏ
vi /data/git/docker/prometheus/prometheus.yml
vi rules.yml
http://localhost:9090/alerts

์ด์ ์๋ฆผ์ด ํ๋ณด๊ฐ ๋ฌ๋ค.
๋ฐ์ด๋๋ฆฌ์ ๋์ปค๋ก ์ฌ๋ฆฌ๋ ๋ฐฉ์ 2๊ฐ์ง๊ฐ ์๋ค. ๋์ปค๋ฅผ ์ฌ์ฉํ๋ค.
vi alertmanager.yml
./alertmanager๋ฅผ ์คํํ๋ฉด ์ด๋ฉ์ผ์ ๋ฐ๋๋ค.
์ด์ ์น๋ธ๋ผ์ฐ์ ๋ฅผ ํตํด ์ ํ์ธํด๋ณด๋ฉด ์์ ์๋ค.
์ฐธ๊ณ
์ฐธ๊ณ