prometheus-alertmanager-webhooks
БесплатноЗапускает вложенные скриптыНе проверенReceive and authenticate Prometheus Alertmanager webhooks. Use when setting up an Alertmanager webhook_configs receiver, verifying the Authorization header…
от hookdeck★ 104 звезды на GitHubОб этом скилле
Prometheus Alertmanager Webhooks
Alertmanager POSTs a version 4 JSON notification to each URL in a receiver's webhook_configs
whenever a group of alerts fires or resolves. Webhooks are not signed. The receiver's
http_config sets an Authorization header on every request, either Bearer <credentials>
(authorization, default type Bearer) or Basic base64(username:password) (basic_auth). Your
endpoint authenticates the request by comparing those credentials with the ones you configured.
Hookdeck's Prometheus Alertmanager source offers both: Basic auth for
basic_auth, where you enter the username and password, and Bearer token for authorization,
where you enter the bare credentials.
Setup note (same as Hookdeck's Prometheus Alertmanager source): "Set basic_auth, or authorization with the default Bearer type, in the webhook receiver's http_config. OAuth 2.0 is not supported."
When to Use This Skill
- How do I receive Prometheus Alertmanager webhooks?
- How do I authenticate requests from an Alertmanager
webhook_configsreceiver? - Does Alertmanager sign webhook payloads? (No: check the
Authorizationcredentials, Bearer or basic_auth) - How do I handle
firingandresolvedalerts and loop overalerts[]? - How do I deduplicate repeated Alertmanager notifications?
- Why does my Alertmanager webhook endpoint return 401?
Verification (core)
const crypto = require('crypto');
// Hash both sides: equal-length buffers, so timingSafeEqual never throws.
function safeEqual(a, b) {
const ha = crypto.createHash('sha256').update(String(a)).digest();
const hb = crypto.createHash('sha256').update(String(b)).digest();
return crypto.timingSafeEqual(ha, hb);
}
const BEARER = /^bearer /i; // auth schemes are case-insensitive (RFC 9110)
const BASIC = /^basic +([A-Za-z0-9+/]+={0,2})$/i;
function verifyAlertmanagerRequest(headers, env = process.env) {
const header = headers['authorization'];
if (typeof header !== 'string' || !header) return false;
if (BEARER.test(header)) { // http_config.authorization (Bearer)
const expected = (env.ALERTMANAGER_WEBHOOK_SECRET || '').replace(BEARER, ''); // bare secret
return Boolean(expected) && safeEqual(header.replace(BEARER, ''), expected);
}
const m = BASIC.exec(header); // http_config.basic_auth
const user = env.ALERTMANAGER_WEBHOOK_USERNAME;
const pass = env.ALERTMANAGER_WEBHOOK_PASSWORD;
if (!m || !user || !pass) return false; // not Basic, or basic_auth not configured
const buf = Buffer.from(m[1], 'base64');
if (buf.toString('base64') !== m[1]) return false; // canonical base64 only
const decoded = buf.toString('utf8');
const i = decoded.indexOf(':'); // FIRST colon: a password may contain ':'
if (i === -1) return false;
const userOk = safeEqual(decoded.slice(0, i), user);
const passOk = safeEqual(decoded.slice(i + 1), pass); // evaluate both, no short-circuit
return userOk && passOk;
}
authorization:Authorization: Bearer <credentials>. Store just the secret (noBearerprefix) inALERTMANAGER_WEBHOOK_SECRET; a leadingBearerin the configured value is stripped. Do not trim or otherwise alter the secret.basic_auth:Authorization: Basic base64(username:password), checked againstALERTMANAGER_WEBHOOK_USERNAMEandALERTMANAGER_WEBHOOK_PASSWORD. Split on the first colon (a password may contain:) and compare both parts. TheBasicscheme matches in any case. Alertmanager sendsbasic_authon every request, so no challenge round trip is needed.- A form you haven't configured is rejected, so with neither configured every request is rejected.
- Return
401for a missing header, wrong scheme or mismatch,400for a body that isn't a JSON object,200once handled. - Read the body raw (
express.raw({ type: '*/*' })) so any content type works, and authenticate before parsing it. - Python:
hmac.compare_digeston bytes (encode both sides; passingstrraises on non-ASCII).
A static shared credential authenticates the sender, not the body, and gives no replay protection (there is no signature and no timestamp). Serve the endpoint over HTTPS and rotate the credential if it leaks.
For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.
Payload and Statuses
Alertmanager has no event-type field. The body is a version "4" notification:
version, groupKey, truncatedAlerts, status, receiver, groupLabels, commonLabels,
commonAnnotations, externalURL, notification_reason, and alerts[] (each with status, labels, annotations,
startsAt, endsAt, generatorURL, fingerprint).
| Status | Meaning |
|---|---|
firing |
The alert (or group) is active |
resolved |
The alert is no longer active (sent when `send_reso |
Установить prometheus-alertmanager-webhooks в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл prometheus-alertmanager-webhooks?
Receive and authenticate Prometheus Alertmanager webhooks. Use when setting up an Alertmanager webhook_configs receiver, verifying the Authorization header from http_config (Bearer credentials or basic_auth), debugging 401s, or handling firing and resolved alert groups.
Как установить скилл prometheus-alertmanager-webhooks?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл prometheus-alertmanager-webhooks запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic