이번에 진행할 예정인 툴은 Prometheus 와 Blackbox Exporter를 통해 서버들의 간단한 헬스체크를 할 수 있는 프로그램을 만들어 보는 걸 진행해 보려 했습니다.
사실 ICMP를 통해 핼스체크를 하는 방식은 서버를 실제 운영하는 데이터센터의 관리방법과는 큰 차이가 있지만, 이번에 구축할 프로젝트는 간단하게 구성만 해보려고 하는 거라 이후에 추가로 업데이트 하면서 작업할 예정입니다.
서버의 상태를 모니터링하면서 agent 설치 없이 ping(ICMP) 기반 헬스체크를 구성할 수 없을까?라는 생각으로 구축을 진행을 하였습니다.
이번 포스트에서는 Prometheus + Blackbox Exporter를 활용해 agentless 방식으로 GPU 서버를 모니터링하는 방법을 정리합니다.
Docker 기반으로 구성하며, ICMP를 이용해 서버가 살아있는지를 체크합니다.
📚 목차
- 개요
- Docker 네트워크 구성
- Blackbox Exporter 설치
- Prometheus 설정 및 연결
- ICMP 모듈 테스트
1. 🔍 개요
- 목표: 서버의 "생존 여부(ping 응답)"를 Prometheus로 모니터링
- 제약: 서버에는 agent(exporter)를 설치할 수 없음
- 해결: Prometheus가 Blackbox Exporter에게 /probe 요청 → Exporter가 대상 서버에 ICMP 요청을 날림
2. 🐳 Docker 네트워크 구성
docker network create monitor
Prometheus와 Blackbox Exporter가 통신하려면 같은 네트워크에 있어야 합니다.
3. ⚙️ Blackbox Exporter 설치
docker run -d --name blackbox-exporter --network monitor \
--cap-add=NET_RAW \
--cap-add=NET_ADMIN \
-p 9115:9115 prom/blackbox-exporter
- NET_RAW 권한은 ICMP 사용을 위해 필요합니다.
4. 📊 Prometheus 설정
prometheus.yml 설정 예시:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'icmp_ping'
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets:
- 8.8.8.8
- 1.1.1.1
- 192.168.x.x # 서버 예시
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115
Prometheus Container 생성
docker run -d --name prometheus \
--network monitor \
-p 9090:9090 \
-v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
주의: prometheus.yml은 반드시 /etc/prometheus/prometheus.yml 경로에 마운트되어야 합니다.
-v ./prometheus.yml:/etc/prometheus/prometheus.yml
5. ✅ ICMP 모듈 테스트
🔹 Prometheus UI 접속
- URL: http://localhost:9090/targets
- http://localhost:9090 에 접속하셔서 상단 status -> targets에 접속하셔도 확인이 가능 합니다.
- icmp_ping job 존재 확인
- 대상 서버들이 UP 상태인지 확인
🔹 메트릭 검색
Prometheus UI → Graph 탭에서:
- probe_success → 서버 생존 여부 (1=정상, 0=실패)
- probe_icmp_duration_seconds → ping 응답 시간
안되는 경우
- URL에 http://localhost:9115/probe?target=8.8.8.8&module=icmp로 입력하셔서 정상적으로 값이 나오는지 확인해봐야 합니다. (Blackbox exporter측 확인)
📦 docker-compose.yml 작성
version: "3.8"
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
depends_on:
- blackbox-exporter
networks:
- monitor
blackbox-exporter:
image: prom/blackbox-exporter:latest
container_name: blackbox-exporter
cap_add:
- NET_RAW
- NET_ADMIN
ports:
- "9115:9115"
networks:
- monitor
networks:
monitor:
driver: bridge
'Infra' 카테고리의 다른 글
SSH 리버스 프록시 기반 원격 지원 시스템 구성 가이드 (0) | 2025.04.16 |
---|---|
Prometheus + Blackbox Exporter로 서버 ICMP(Ping) Health Check 구성하기 (3) (0) | 2025.04.09 |
Prometheus + Blackbox Exporter로 서버 ICMP(Ping) Health Check 구성하기#2 (0) | 2025.04.08 |