Blackbox Exporter
Blackbox Exporter는 HTTP, TCP, ICMP 등의 프로토콜을 사용하여 외부 서비스와 엔드포인트의 가용성을 능동적으로 모니터링하는 도구입니다. Lumie 인프라에서는 운영 중인 웹 서비스들의 상태를 주기적으로 확인하고 장애 시 즉시 알림을 발송합니다.
배포 구성
- 네임스페이스:
blackbox-exporter - 차트:
prometheus-blackbox-exporterv9.2.0 - 이미지:
zot.lumie-infra.com/prometheus/blackbox-exporter:v0.25.0 - 복제본: 1개
아키텍처
프로브 모듈 구성
Blackbox Exporter는 서비스 특성에 따라 여러 프로브 모듈을 제공합니다.
http_2xx (기본 HTTP 검사)
http_2xx:
prober: http
timeout: 10s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
valid_status_codes: [200, 301, 302, 303]
method: GET
follow_redirects: true
preferred_ip_protocol: ip4
tls_config:
insecure_skip_verify: false
- TLS 인증서 검증 활성화
- 리다이렉트 자동 추적
- IPv4 우선 사용
http_2xx_insecure (TLS 검증 생략)
http_2xx_insecure:
prober: http
timeout: 10s
http:
tls_config:
insecure_skip_verify: true
자체 서명 인증서를 사용하는 내부 서비스 모니터링 시 사용합니다.
http_auth_ok (인증 필요 서비스)
http_auth_ok:
prober: http
timeout: 10s
http:
valid_status_codes: [200, 301, 302, 303, 401]
follow_redirects: false
401 Unauthorized 응답도 정상으로 간주하여 인증이 필요한 서비스의 가용성을 확인합니다.
tcp_connect / icmp
tcp_connect:
prober: tcp
timeout: 5s
icmp:
prober: icmp
timeout: 5s
icmp:
preferred_ip_protocol: ip4
모니터링 대상
ServiceMonitor를 통해 다음 서비스들 이 60초 간격으로 모니터링됩니다:
| 대상 이름 | URL | 모듈 |
|---|---|---|
joossameng | https://joossameng.com | http_2xx |
lumie | https://lumie-edu.com | http_2xx |
lumie-infra | https://lumie-infra.com | http_2xx |
jaejadle | https://www.disciples-church.com | http_2xx |
serviceMonitor:
enabled: true
defaults:
interval: 60s
scrapeTimeout: 30s
module: http_2xx
additionalLabels:
release: prometheus
알림 규칙
프로브 실패 감지
- alert: BlackboxProbeFailed
expr: probe_success == 0
for: 5m
labels:
severity: critical
annotations:
summary: "Blackbox probe failed for {{ $labels.target }}"
description: "Probe {{ $labels.instance }} has been failing for more than 5 minutes."
probe_success == 0 상태가 5분 이상 지속되면 critical 알림을 발송합니다.
응답 지연 감지
- alert: BlackboxSlowProbe
expr: avg_over_time(probe_duration_seconds[5m]) > 5
for: 5m
labels:
severity: warning
annotations:
summary: "Blackbox slow probe for {{ $labels.target }}"
5분 평균 응답 시간이 5초를 초과하면 warning 알림을 발송합니다.
SSL 인증서 만료 경고
- alert: BlackboxSslCertificateWillExpireSoon
# Vercel이 자동 갱신하는 외부 관리 대상 제외
expr: (probe_ssl_earliest_cert_expiry{target!~"joossameng|jaejadle"} - time()) / 86400 < 30
for: 1h
labels:
severity: warning
- alert: BlackboxSslCertificateExpired
expr: (probe_ssl_earliest_cert_expiry{target!~"joossameng|jaejadle"} - time()) <= 0
for: 5m
labels:
severity: critical
joossameng,jaejadle는 Vercel이 Let's Encrypt 인증서를 자동 갱신하므로 규칙에서 제외- 나머지 대상은 인증서 만료 30일 전
warning, 만료 시critical알림
리소스 설정
resources:
requests:
cpu: 15m
memory: 100Mi
limits:
memory: 100Mi # CPU 제한 없음 (안정성 우선)
파드 배치
여러 노드에 분산 배치되도록 Anti-Affinity 설정이 적용되어 있습니다:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- prometheus-blackbox-exporter
topologyKey: kubernetes.io/hostname
주요 메트릭
| 메트릭 | 설명 |
|---|---|
probe_success | 프로브 성공 여부 (1=성공, 0=실패) |
probe_duration_seconds | 프로브 완료까지 소요 시간 |
probe_http_status_code | HTTP 응답 상태 코드 |
probe_ssl_earliest_cert_expiry | SSL 인증서 만료 시각 (Unix timestamp) |
probe_http_version | 사용된 HTTP 버전 |
문제 해결
프로브 실패 확인
# Blackbox Exporter 파드 상태 확인
kubectl get pods -n blackbox-exporter
# 특정 URL에 대한 수동 프로브 실행
kubectl exec -n blackbox-exporter deploy/blackbox-exporter -- \
wget -qO- "http://localhost:9115/probe?target=https://lumie-edu.com&module=http_2xx"
# 프로브 결과 전체 출력
kubectl port-forward -n blackbox-exporter svc/blackbox-exporter 9115:9115
curl "http://localhost:9115/probe?target=https://lumie-edu.com&module=http_2xx&debug=true"
ServiceMonitor 확인
# ServiceMonitor 등록 확인
kubectl get servicemonitors -n blackbox-exporter
# Prometheus 타겟 상태 확인
kubectl port-forward -n prometheus svc/prometheus-kube-prometheus-prometheus 9090:9090
# http://localhost:9090/targets 에서 blackbox 타겟 확인
포트 포워딩
# Blackbox Exporter UI 접근
kubectl port-forward -n blackbox-exporter svc/blackbox-exporter 9115:9115
# http://localhost:9115 에서 수동 프로브 실행 가능