Alert Webhook
Overview
Prometheus 의 알람을 CloudOps 로 보내려면 Alertmanager 에서 발화한 알람을 CloudOps webhook 엔드포인트로 가리키는 webhook receiver 로 전달하도록 설정하고, 해당 receiver 가 받을 alert rule 을 Prometheus 에 정의합니다.
본 가이드는 vanilla Prometheus 2.x+ 와 Alertmanager 0.27+ 기준입니다. CloudOps 의 Prometheus source plugin 은 표준 Alertmanager Webhook v4 payload 를 수신합니다.
필요 정보:
- CloudOps webhook URL — CloudOps 콘솔에서 Prometheus webhook source 를 등록할 때 발급되는 엔드포인트. 먼저 CloudOps 에 Prometheus 연동하기 단계로 이 값을 확보하세요. URL 형태:
https://<external-host>/integration-hub/webhooks/<webhook-id>/<token>/webhook-ingest. - Prometheus 와 Alertmanager 가 동작하는 호스트에 대한 shell 접근 권한,
alertmanager.yml/alert.rules.yml수정 + config reload 권한.
설정은 아래 순서로 진행합니다.
- Alertmanager 에 webhook receiver 추가
- Prometheus 에 alert rule 정의
- 연동 테스트
route (또는 하위 routes: 항목) 가 가리킬 때만 receiver 로 전달하므로, 1단계 예시에서 route 와 receiver 를 함께 묶어줍니다.1. Alertmanager 에 Webhook Receiver 추가
receiver 는 Alertmanager 가 발화한 알람을 어디로 보낼지 정의합니다. CloudOps 의 경우 내장 webhook_configs 블록을 사용합니다.
alertmanager.yml 편집
Alertmanager 설정 파일을 엽니다 (기본 경로: /etc/alertmanager/alertmanager.yml). receivers: 항목과 대응되는 route: 블록을 추가합니다.
global:
resolve_timeout: 1m
route:
receiver: cloudops-webhook
group_by: [alertname]
group_wait: 0s
group_interval: 30s
repeat_interval: 5m
receivers:
- name: cloudops-webhook
webhook_configs:
- url: '<CLOUDOPS_WEBHOOK_URL>'
send_resolved: true<CLOUDOPS_WEBHOOK_URL> 자리에 CloudOps 콘솔에서 복사한 Webhook URL 을 붙여넣으세요.
send_resolved: true 는 resolved 알람도 함께 전송하여 CloudOps 가 해당 이벤트를 종료 (event_type=RECOVERY) 처리하게 합니다. firing 만 추적하려면 false 로 설정하세요.이미 기본 receiver 가 설정되어 있다면 덮어쓰지 마세요. cloudops-webhook 을 추가 receivers: 항목으로 더한 뒤, route: 의 하위 routes: 블록으로 라우팅하세요. 예시:
route:
receiver: existing-default
routes:
- receiver: cloudops-webhook
matchers:
- severity =~ "critical|warning"
continue: falseAlertmanager reload
재시작 없이 새 config 를 적용합니다.
# 기본 시그널 핸들러
kill -HUP $(pidof alertmanager)
# 또는, --web.enable-lifecycle 옵션으로 기동했다면
curl -X POST http://localhost:9093/-/reloadAlertmanager UI (http://localhost:9093) 의 [Status > Config] 에서 새 receiver 가 표시되는지 확인합니다.
2. Prometheus 에 Alert Rule 정의
알람은 Prometheus 가 평가하는 rule group 에서 발생합니다. Prometheus 가 발화한 알람만 CloudOps 가 수신할 수 있습니다.
alert.rules.yml 편집
rule group 파일을 추가하거나 확장합니다 (예시 경로: /etc/prometheus/alert.rules.yml).
groups:
- name: cloudops-integration
interval: 1m
rules:
- alert: CloudOpsHighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 2m
labels:
severity: critical
team: platform
annotations:
summary: "High 5xx error rate on {{ $labels.service }}"
description: "5xx error rate exceeded 5% for 2 minutes"labels 는 Alertmanager 에서 알람의 라벨로 사용됩니다 (route / routes: 매칭 기준). annotations 는 CloudOps 에 표시되는 사람이 읽는 요약입니다.
prometheus.yml 에 rule file 등록
prometheus.yml (기본: /etc/prometheus/prometheus.yml) 를 열어 rule_files 항목에 rule file 경로를 추가하고, alerting.alertmanagers 블록이 없다면 함께 추가합니다.
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093 # Alertmanager host:port 에 맞춰 조정
rule_files:
- /etc/prometheus/alert.rules.ymlPrometheus reload
# 기본 시그널 핸들러
kill -HUP $(pidof prometheus)
# 또는, --web.enable-lifecycle 옵션으로 기동했다면
curl -X POST http://localhost:9090/-/reloadPrometheus UI (http://localhost:9090) 의 [Status > Rules] 에서 새 rule group 이 state: ok 로 보이는지 확인합니다.
3. 연동 테스트
실 운영 알람이 의존하기 전에 Prometheus → Alertmanager → CloudOps 경로가 정상 동작하는지 검증합니다.
강제 발화로 빠른 검증
룰의 expr 을 일시적으로 vector(1) 로 교체합니다. 이 상수는 항상 true 라 다음 평가 시점에 즉시 발화합니다.
- alert: CloudOpsE2ETrigger
expr: vector(1)
for: 0s
labels:
severity: critical
annotations:
summary: "CloudOps webhook integration test"Prometheus reload 후 1 evaluation 주기 (기본: 1분) 를 기다립니다.
CloudOps 측 확인
CloudOps 콘솔에서 등록한 webhook source 의 행에서 Requests (24h) 카운트가 ~1분 내 증가하는지 확인합니다.
수신되지 않은 경우:
webhook_configs.url이 CloudOps 가 발급한 값과 정확히 일치하는지 확인.route(또는 하위routes:항목) 가 새 receiver 로 라우팅하는지 확인 — Alertmanager UI [Status > Config].- Alertmanager UI [Status > Alerts] 에 firing alert 가 있는지 확인. 없다면 룰이 발화하지 않은 것 — Prometheus UI [Alerts] 확인.
- Alertmanager 로그에서
notify전송 오류 여부 확인.
RECOVERY 흐름 검증 (선택)
resolved 경로까지 검증하려면 테스트 룰의 expr 을 vector(1) 에서 vector(0) 으로 바꾸고 Prometheus 를 reload 합니다. Alertmanager 는 repeat_interval 내에 resolved 상태 webhook 을 전송하고 CloudOps 는 이를 event_type=RECOVERY 로 기록합니다.
원래 expression 복구
검증 후 원래 expr 로 복구하고 Prometheus 를 reload 합니다.
(선택) Docker Compose 로 로컬 sandbox
운영 Prometheus 를 건드리지 않고 통합을 처음부터 끝까지 시험할 수 있는 격리 sandbox 가 필요하다면 아래 최소 Docker Compose 스택으로 Prometheus + Alertmanager 한 쌍을 새로 띄울 수 있습니다.
# docker-compose.yml
services:
prometheus:
image: prom/prometheus:v3.0.1
ports: ["9090:9090"]
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./alert.rules.yml:/etc/prometheus/alert.rules.yml:ro
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--web.enable-lifecycle'
restart: unless-stopped
alertmanager:
image: prom/alertmanager:v0.28.0
ports: ["9093:9093"]
volumes:
- ./alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
restart: unless-stopped위 1, 2 단계의 alertmanager.yml, alert.rules.yml, prometheus.yml 조각과 결합하세요. docker compose up -d 로 localhost:9090 (Prometheus) 와 localhost:9093 (Alertmanager) 가 기동됩니다. 정리는 docker compose down.