๐น ๊ฐ์
์ด๋ฒ ๊ธ์์๋ Istio์์ Prometheus์ Grafana๋ฅผ ํ์ฉํ์ฌ ์๋น์ค ๋ฉํธ๋ฆญ์ ์์งํ๊ณ ๋ชจ๋ํฐ๋ง์ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
Istio๋ Envoy ํ๋ก์๋ฅผ ํตํด ์๋น์ค ํธ๋ํฝ ๋ฐ์ดํฐ๋ฅผ ์์งํ๋ฉฐ,
์ด๋ฅผ Prometheus๋ฅผ ํตํด ์ ์ฅํ๊ณ , Grafana๋ฅผ ํ์ฉํ์ฌ ์๊ฐํํ ์ ์์ต๋๋ค.
์ด ๊ธ์์๋ Prometheus ๋ฐ Grafana์ ๊ฐ๋ , Istio์์ ๋ฉํธ๋ฆญ์ ์์งํ๋ ๋ฐฉ๋ฒ, ๋ชจ๋ํฐ๋ง ๋์๋ณด๋ ๊ตฌ์ฑ ๋ฐฉ๋ฒ์ ์ค๋ช ํ๊ฒ ์ต๋๋ค.
๐น 1. Istio์์ Prometheus & Grafana๊ฐ ํ์ํ ์ด์
โ 1.1 Prometheus๋?
Prometheus๋ ์คํ์์ค ๋ชจ๋ํฐ๋ง ๋ฐ ์๋ฆผ ์์คํ
์ผ๋ก,
์ ํ๋ฆฌ์ผ์ด์
๋ฐ ์๋น์ค์์ ์ค์๊ฐ ๋ฉํธ๋ฆญ ๋ฐ์ดํฐ๋ฅผ ์์งํ๊ณ ์ ์ฅํ๋ ์ญํ ์ ํฉ๋๋ค.
Prometheus์ ์ฃผ์ ๊ธฐ๋ฅ
- ์๊ณ์ด(Time-Series) ๊ธฐ๋ฐ ๋ฐ์ดํฐ ์ ์ฅ ๋ฐ ๋ถ์
- HTTP ๊ธฐ๋ฐ์ ๊ฐ๋ ฅํ ์ฟผ๋ฆฌ ์ธ์ด(PromQL) ์ ๊ณต
- ์ ํ๋ฆฌ์ผ์ด์ ๋ฐ ์ธํ๋ผ ๋ฉํธ๋ฆญ์ ์ค์๊ฐ ๋ชจ๋ํฐ๋ง
- ์๋ฆผ ์์คํ (Alertmanager)๊ณผ ์ฐ๋ ๊ฐ๋ฅ
โ 1.2 Grafana๋?
Grafana๋ Prometheus ๋ฑ์ ๋ชจ๋ํฐ๋ง ๋ฐ์ดํฐ๋ฅผ ์๊ฐํํ๋ ๋์๋ณด๋ ํด์ ๋๋ค.
Grafana์ ์ฃผ์ ๊ธฐ๋ฅ
- Prometheus์ ์ฐ๋ํ์ฌ ์ค์๊ฐ ๋ฐ์ดํฐ ์๊ฐํ
- ๋์๋ณด๋๋ฅผ ํ์ฉํ์ฌ ์๋น์ค ์ํ ๋ชจ๋ํฐ๋ง ๊ฐ๋ฅ
- Istio ๋ฉํธ๋ฆญ(ํธ๋ํฝ, ์ค๋ฅ์จ, ์ง์ฐ ์๊ฐ ๋ฑ)์ ๋ถ์ํ๋ ๋ฐ ์ต์ ํ
๐ก Istio์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก Prometheus์ Grafana๋ฅผ ์ง์ํ๋ฉฐ, ์ด๋ฅผ ํ์ฉํ์ฌ ๋คํธ์ํฌ ํธ๋ํฝ ๋ฐ ์๋น์ค ์ํ๋ฅผ ๋ชจ๋ํฐ๋งํ ์ ์์ต๋๋ค.
๐น 2. Istio์์ Prometheus ์ค์น ๋ฐ ์ค์
โ 2.1 Istio์ ํจ๊ป Prometheus ์ค์นํ๊ธฐ
Istio์๋ ๊ธฐ๋ณธ์ ์ผ๋ก Prometheus๊ฐ ํฌํจ๋์ด ์์ผ๋ฉฐ, Helm Chart๋ฅผ ์ฌ์ฉํ์ฌ ์ค์นํ ์ ์์ต๋๋ค.
helm repo add istio https://istio-release.storage.googleapis.com/charts
helm repo update
helm install istio-base istio/base -n istio-system --create-namespace
helm install istiod istio/istiod -n istio-system
helm install istio-prometheus istio/prometheus -n istio-system
๐ก istio/prometheus Helm Chart๋ฅผ ์ค์นํ๋ฉด Istio์ ๋ฉํธ๋ฆญ์ ์๋์ผ๋ก ์์งํ ์ ์์ต๋๋ค.
โ 2.2 Prometheus ์๋น์ค ํ์ธ
์ค์น๊ฐ ์๋ฃ๋๋ฉด Prometheus๊ฐ ์ ์์ ์ผ๋ก ์คํ๋๊ณ ์๋์ง ํ์ธํฉ๋๋ค.
kubectl get pods -n istio-system | grep prometheus
์ถ๋ ฅ ์์ :
istio-prometheus-5c6d87f7bb-8p7z7 1/1 Running 0 10m
โ 2.3 Prometheus ์น UI ์ ์
Prometheus์ ์น UI์ ์ ์ํ๋ ค๋ฉด ํฌํธ๋ฅผ ํฌ์๋ฉํฉ๋๋ค.
kubectl port-forward -n istio-system svc/istio-prometheus 9090:9090
์น ๋ธ๋ผ์ฐ์ ์์ http://localhost:9090 ์ ์ ์ํ๋ฉด Prometheus UI๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
๐ก PromQL์ ํ์ฉํ์ฌ Istio ๋ฉํธ๋ฆญ์ ์ง์ ์กฐํํ ์ ์์ต๋๋ค.
๐น 3. Istio์์ Grafana ์ค์น ๋ฐ ๋์๋ณด๋ ๊ตฌ์ฑ
โ 3.1 Istio์ ํจ๊ป Grafana ์ค์นํ๊ธฐ
Istio๋ ๊ธฐ๋ณธ์ ์ผ๋ก Grafana ๋์๋ณด๋๋ฅผ ํฌํจํ๊ณ ์์ผ๋ฉฐ, Helm Chart๋ฅผ ์ฌ์ฉํ์ฌ ์ค์นํ ์ ์์ต๋๋ค.
helm install istio-grafana istio/grafana -n istio-system
โ 3.2 Grafana ์๋น์ค ํ์ธ ๋ฐ ์ ์
Grafana๊ฐ ์ ์์ ์ผ๋ก ์คํ๋๊ณ ์๋์ง ํ์ธํฉ๋๋ค.
kubectl get pods -n istio-system | grep grafana
์ถ๋ ฅ ์์ :
istio-grafana-6b798fbdc8-txz8m 1/1 Running 0 5m
Grafana UI์ ์ ์ํ๋ ค๋ฉด ํฌํธ๋ฅผ ํฌ์๋ฉํฉ๋๋ค.
kubectl port-forward -n istio-system svc/istio-grafana 3000:3000
์น ๋ธ๋ผ์ฐ์ ์์ http://localhost:3000 ์ ์ ์ํ๋ฉด Grafana UI๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
โ 3.3 Grafana์์ Istio ๋์๋ณด๋ ํ์ธ
Grafana์์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ ๊ณตํ๋ Istio ๋์๋ณด๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
1๏ธโฃ Istio Mesh Dashboard → Istio ์๋น์ค ์ ์ฒด ์ํ ๋ชจ๋ํฐ๋ง
2๏ธโฃ Istio Service Dashboard → ํน์ ์๋น์ค์ ํธ๋ํฝ, ์ค๋ฅ์จ, ์๋ต ์๊ฐ ํ์ธ
3๏ธโฃ Istio Workload Dashboard → ํน์ ์ํฌ๋ก๋(Pod) ์์ค์ ์ฑ๋ฅ ๋ชจ๋ํฐ๋ง
4๏ธโฃ Istio Control Plane Dashboard → Istio์ ์ปจํธ๋กค ํ๋ ์ธ ์ฑ๋ฅ ๋ถ์
๐ก Grafana์ ๊ธฐ๋ณธ Istio ๋์๋ณด๋๋ฅผ ํ์ฉํ๋ฉด, ์๋น์ค์ ํธ๋ํฝ ๋ฐ ์ฑ๋ฅ ์ํ๋ฅผ ์ฝ๊ฒ ๋ชจ๋ํฐ๋งํ ์ ์์ต๋๋ค.
๐น 4. Prometheus & Grafana๋ฅผ ํ์ฉํ Istio ๋ฉํธ๋ฆญ ๋ถ์
โ 4.1 ์ฃผ์ Prometheus ๋ฉํธ๋ฆญ ์กฐํ
Prometheus์์ ๋ค์๊ณผ ๊ฐ์ Istio ๊ด๋ จ ๋ฉํธ๋ฆญ์ ์กฐํํ ์ ์์ต๋๋ค.
๋ฉํธ๋ฆญ | ์ค๋ช |
istio_requests_total | ์๋น์ค ๊ฐ ์์ฒญ ์ด ๊ฐ์ |
istio_request_duration_milliseconds | ์์ฒญ ์ฒ๋ฆฌ ์๊ฐ(์ง์ฐ ์๊ฐ) |
istio_tcp_sent_bytes_total | TCP ํธ๋ํฝ ์ ์ก๋ |
istio_tcp_received_bytes_total | TCP ํธ๋ํฝ ์์ ๋ |
Prometheus์์ ํน์ ์๋น์ค์ ์์ฒญ ์๋ฅผ ํ์ธํ๋ ์ฟผ๋ฆฌ ์์ :
istio_requests_total{destination_service="my-service.default.svc.cluster.local"}
๐ก ์ด ์ฟผ๋ฆฌ๋ฅผ ์คํํ๋ฉด my-service ์๋น์ค๋ก ๋ค์ด์จ ์์ฒญ ์๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
โ 4.2 Grafana์์ Istio ํธ๋ํฝ ๋ชจ๋ํฐ๋ง
Grafana์ Istio Service Dashboard์์ ๋ค์๊ณผ ๊ฐ์ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
- ์๋น์ค ๋ณ ์์ฒญ ์, ์๋ต ์๋ ๋ฐ ์ค๋ฅ์จ
- HTTP ๋ฐ TCP ํธ๋ํฝ๋
- ์๋น์ค ๊ฐ ํธ๋ํฝ ํ๋ฆ ๋ฐ ์ฑ๋ฅ
๐ ๊ฒฐ๋ก
- Istio์์ Prometheus๋ฅผ ํ์ฉํ์ฌ ์ค์๊ฐ ์๋น์ค ๋ฉํธ๋ฆญ์ ์์งํ ์ ์์ต๋๋ค.
- Grafana๋ฅผ ํ์ฉํ๋ฉด Prometheus์์ ์์งํ ๋ฐ์ดํฐ๋ฅผ ๋์๋ณด๋๋ก ์๊ฐํํ์ฌ ์ฝ๊ฒ ๋ชจ๋ํฐ๋งํ ์ ์์ต๋๋ค.
- Istio์ ๊ธฐ๋ณธ ๋์๋ณด๋(Istio Mesh, Service, Workload Dashboard)๋ฅผ ํ์ฉํ์ฌ ๋คํธ์ํฌ ๋ฐ ์๋น์ค ์ฑ๋ฅ์ ๋ถ์ํ ์ ์์ต๋๋ค.
- Prometheus์ PromQL์ ์ฌ์ฉํ์ฌ ํน์ ์๋น์ค์ ์์ฒญ ์, ์ค๋ฅ์จ, ์๋ต ์๋ ๋ฑ์ ์์ธํ ๋ถ์ํ ์ ์์ต๋๋ค.