К основному содержанию
скилл CX Codex

authoring-log-alerts — скилл для Claude Code: алерты по логам PostHog

Помогает настроить алерты по логам в проекте PostHog: выбирает сервисы, считает базовую линию и подбирает порог, чтобы алерт срабатывал 0–3 раза в неделю.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add PostHog/skills --skill authoring-log-alerts -a claude-code
Открыть на GitHub

Что делает authoring-log-alerts

Скилл ведёт агента по шагам: сначала вызывает posthog:logs-services за последние 24 часа и отбирает сервисы-кандидаты. Кандидат — тот, у которого объём логов нетривиальный и есть ненулевой error_rate, либо сервис назвал пользователь.

Дальше агент при необходимости сужает фильтр через posthog:logs-attributes-list и posthog:logs-attribute-values-list, а базовую линию считает через posthog:logs-count-ranges за -7d. Ответ прогоняется через scripts/baseline_stats.py, который возвращает suggested_threshold_count и флаги здоровья распределения — sparse, empty, spiky, flat. Черновик проверяется на истории через posthog:logs-alerts-simulate-create, а затем сохраняется и привязывается к Slack, вебхуку или Microsoft Teams.

Важная деталь: во время подбора алерта скилл не разрешает вызывать posthog:query-logs — нужны распределения, а не строки. Если сервис уже покрыт алертом, это другая задача: смотрите posthog:logs-alerts-events-list и posthog:logs-alerts-partial-update.

Какие задачи решает

  • подобрать порог алерта, который не будет срабатывать каждый час
  • оценить, даёт ли сервис вообще сигнал, пригодный для алерта
  • собрать стартовый набор алертов сразу после включения логирования
  • сузить фильтр по http.status_code или error.type, чтобы не ловить все ошибки подряд
  • проверить черновик алерта на истории за неделю до публикации

Примеры запросов агенту

  • Настрой алерты по логам для моего проекта PostHog
  • Посмотри сервисы за сутки и предложи, на что стоит повесить алерт
  • Проверь черновик алерта через simulate на истории за -7d

Как установить authoring-log-alerts

1Через Skills CLI (Vercel)

npx skills add PostHog/skills --skill authoring-log-alerts -a claude-code

2Вручную: положить файлы

~/.claude/skills/authoring-log-alerts/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/authoring-log-alerts/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о authoring-log-alerts

Как установить authoring-log-alerts в Claude?

Выполните npx skills add PostHog/skills --skill authoring-log-alerts -a claude-code. После этого скилл появится в ~/.claude/skills/authoring-log-alerts/SKILL.md.

Что делает authoring-log-alerts?

Проводит агента по пяти шагам: отбор сервисов, сужение фильтра, расчёт базовой линии за 7 дней, проверка черновика через simulate и публикация алерта с уведомлением.

Чем этот скилл отличается от настройки уже существующего алерта?

Он предназначен для создания новых алертов. Для правки существующего используются posthog:logs-alerts-events-list и posthog:logs-alerts-partial-update.

Исходный текст

SKILL.md · MIT
---
name: authoring-log-alerts
description: >
  Author useful, low-noise log alerts on services in a PostHog project. Use when the user asks to set up
  alerts for their logs, suggest alerts they should add, or evaluate whether a service is worth monitoring.
  Covers service triage, baseline characterisation, threshold drafting, back-testing via simulate, and
  shipping with a notification destination.
---

# Authoring log alerts

Authoring an alert is a _measurement_ problem, not a guessing problem. You are not trying to be exhaustive — you
are trying to land thresholds that fire 0–3 times per week on real production patterns, on services that matter.

## When to use this skill

- The user asks to "set up alerts" / "suggest alerts" for their project.
- The user wants to evaluate whether a service is producing alertable signal.
- The user has just enabled log alerting and wants a starter set.

## When _not_ to use this skill

- Tuning an alert that already exists — that's a different job (use `posthog:logs-alerts-events-list` to inspect
  fire/resolve cadence and `posthog:logs-alerts-partial-update` to adjust).
- Investigating an active incident — pull rows with `posthog:query-logs`, don't author an alert mid-incident.

## Tools

| Tool                                                                  | Job                                                                           | Where it fits      |
| --------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------ |
| `posthog:logs-services`                                               | Top-25 services in window with log_count, error_count, error_rate, sparkline. | Step 1 — triage.   |
| `posthog:logs-attributes-list` / `posthog:logs-attribute-values-list` | Discover keys/values for narrower filters.                                    | Step 2, optional.  |
| `posthog:logs-count-ranges`                                           | Adaptive time-bucketed counts for a filter.                                   | Step 3 — baseline. |
| `posthog:logs-alerts-simulate-create`                                 | Replay a draft config against `-7d` history with full state machine.          | Step 4 — validate. |
| `posthog:logs-alerts-create`                                          | Persist the alert.                                                            | Step 5 — ship.     |
| `posthog:logs-alerts-destinations-create`                             | Wire the alert to Slack, webhook, or Microsoft Teams.                         | Step 5: ship.      |

Do **not** call `posthog:query-logs` during authoring. You need distributions, not rows. Reserve `posthog:query-logs` for
the very end if the user asks "show me a sample of what would have fired" — `limit: 10` is plenty.

## Workflow

### 1. Triage — pick candidate services

Call `posthog:logs-services` for the last 24h with no filters. The response is capped at 25 services and includes a
sparkline, so it is small and bounded.

A service is a candidate when **both** are true:

- `log_count` is non-trivial (≥ ~1k in 24h — quieter services produce too little signal to alert on).
- `error_rate` is non-zero, **or** the user has named the service explicitly.

Skip services with high volume but `error_rate == 0` unless the user wants a volume-shape alert (e.g. "warn me
if api-gateway suddenly stops producing logs"). Volume-floor alerts use `threshold_operator: below` and need
different reasoning — see [references/volume-floor-alerts.md](./references/volume-floor-alerts.md).

If the user names a service, treat it as a candidate even without error signal.

### 2. (Optional) Narrow the filter

If a service has many error sub-types, an alert on "all errors" is usually too broad. Use
`posthog:logs-attributes-list` (try `attribute_type: log`) and `posthog:logs-attribute-values-list` to find a discriminator —
common ones are `http.status_code`, `error.type`, `k8s.container.name`. Add the narrowing filter to your draft.

Keep it simple: one severity filter + one or two attribute filters is plenty. Multi-clause filters are
harder to reason about and rarely improve precision.

### 3. Baseline — characterise the candidate over 7 days

Call `posthog:logs-count-ranges` with the candidate's filters, `dateRange: { date_from: "-7d" }`, and
`targetBuckets: 24` (one bucket ≈ 7h). The response gives you bucket counts.

**Do not eyeball the percentiles or scale the threshold to the alert window manually.** Pipe the
count-ranges response into the helper script:

```bash
echo '<count-ranges JSON>' | python3 scripts/baseline_stats.py --window-minutes 5
```

The script returns:

```json
{
  "n_buckets": 12,
  "bucket_minutes": 420.0,
  "alert_window_minutes": 5,
  "stats": { "p50": 12.0, "p95": 71.25, "p99": 126.25, "max": 140 },
  "suggested_threshold_count": 5,
  "rationale": "max(p99=126.25, median*3=36.0, floor=5) scaled from 420m bucket to 5m window",
  "health": []
}
```

Use `suggested_threshold_count` as your starting threshold. Read `health`:

| `health` flag           | What it means                                | What to do                                                                                                 |
| ----------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `sparse:N_of_M_buckets` | Too few non-empty buckets for a 7d baseline. | Widen filter, extend to `-30d`, or skip.                                                                   |
| `empty`                 | All buckets are zero.                        | Skip — no signal.                                                                                          |
| `spiky`                 | `max` is 10×+ `p95`.                         | Count-threshold alerts work well. Proceed.                                                                 |
| `flat`                  | `p95` ≈ `p50`.                               | Be cautious — either no incidents in lookback, or the metric is too smooth. Try a longer lookback or skip. |
| `[]` (empty)            | Healthy distribution.                        | Proceed.                                                                                                   |

### 4. Draft and simulate

Pick a starter draft from these defaults — see [references/threshold-defaults.md](./references/threshold-defaults.md)
for the reasoning:

| Setting               | Default                                     | Notes                                                                 |
| --------------------- | ------------------------------------------- | --------------------------------------------------------------------- |
| `threshold_count`     | `suggested_threshold_count` from the script | Already scaled to the alert window.                                   |
| `threshold_operator`  | `above`                                     | Use `below` only for volume-floor alerts.                             |
| `window_minutes`      | `5`                                         | Allowed: 5, 10, 15, 30, 60. Must match what you passed to the script. |
| `evaluation_periods`  | `3`                                         | M in N-of-M.                                                          |
| `datapoints_to_alarm` | `2`                                         | N in N-of-M. 2-of-3 reduces flap from a single noisy bucket.          |
| `cooldown_minutes`    | `30`                                        | Minimum time between notifications (fire or resolve).                 |

Call `posthog:logs-alerts-simulate-create` with these settings and `date_from: "-7d"`. The response gives you `fire_count`
and `resolve_count`.

### 5. Iterate — three rounds, then ship or skip

Target: `fire_count` between 0 and ~3 over `-7d`. If outside the band:

| Outcome                                                         | Adjustment                                                                                           |
| --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `fire_count` = 0 over 7d _and_ the baseline was spiky           | Lower `threshold_count` toward `stats.p95` from the script, or drop to 1-of-2.                       |
| `fire_count` = 0 _and_ the baseline was flat                    | The service has no alertable signal. Skip it; log why.                                               |
| `fire_count` > 5                                                | Raise `threshold_count` toward `stats.max` from the script, or move to 3-of-5 for a smoother window. |
| `fire_count` is fine but resolve_count never matches fire_count | Cooldown is too long, or the underlying state is genuinely sticky. Acceptable for now.               |

When adjusting the threshold, **read values from the script's `stats` block — never recompute percentiles
by hand.**

Cap iteration at **3 simulate calls per candidate**. If you can't land in the band in 3 rounds, the metric
is wrong — either the filter is too broad, the window is wrong, or the service genuinely doesn't have a
threshold-shape signal. Note it and move on.

### 6. Ship — create + attach destination

Once a draft simulates cleanly:

1. Call `posthog:logs-alerts-create` with the validated config. Use a name like `<service> error rate (auto)` so the
   user can see at a glance which alerts came from this skill.
2. Call `posthog:logs-alerts-destinations-create` to wire it to a notification target. **An alert with no destination
   is silent.** Supported destination fields:
   - Slack: `type: "slack"`, `slack_workspace_id`, and `slack_channel_id`. `slack_channel_name` is optional.
   - Webhook: `type: "webhook"` and `webhook_url`.
   - Microsoft Teams: `type: "teams"` and `webhook_url`.

   Always confirm the channel name or webhook URL with the user before attaching. Never wire
   an auto-generated alert to a production channel without explicit confirmation. If the user is unsure,
   suggest a low-traffic testing channel for the first few alerts.

If the user wants alerts created in `enabled: false` state for review-then-flip, pass `enabled: false` to
`-create` and tell them how many drafts you produced.

## Filter shape — required

The `filters` field on `posthog:logs-alerts-create` takes a subset of `LogsViewerFilters` and **must contain at
least one of**:

- `severityLevels` — list of `["trace","debug","info","warn","error","fatal"]`
- `serviceNames` — list of service name strings
- `filterGroup` — property filter group

The same shape goes into `posthog:logs-alerts-simulate-create`'s `filters` field. Match the simulate filters to the alert filters
exactly — otherwise the simulation is testing a different alert than the one you ship.

Example minimum:

```json
{
  "severityLevels": ["error", "fatal"],
  "serviceNames": ["api-gateway"]
}
```

## Token-economy rules

- One `posthog:logs-services` call at the start, not per-candidate.
- One `posthog:logs-count-ranges` call per candidate at `targetBuckets: 24`. Don't go above 30 during authoring.
- ≤ 3 `posthog:logs-alerts-simulate-create` calls per candidate.
- Zero `posthog:query-logs` calls during the authoring loop.
- Prefer reporting a small set of well-validated alerts over a long list of unvalidated drafts.

## Output

Report what you did, in this shape:

- For each shipped alert: name, filters, threshold, simulated fire_count over 7d, destination.
- For each skipped candidate: service name + why (flat baseline, can't land threshold, low volume).
- Total simulate calls made, total alerts created.

The user should be able to read this and decide whether to disable any drafts before they go live.

## Related skills

- **`investigating-logs`** — characterize a service's baseline before alerting on it, and investigate firings after
- **`authoring-error-tracking-alerts`** — alert on exceptions rather than log lines

© PostHog · MIT · PostHog/skills

Похожие скиллы

Всё по теме «DevOps и инфраструктура» →
cx-alerts coralogix Скилл для работы с алертами Coralogix из терминала: список, создание, включение и выключение через cx alerts. Пригодится, когда дежурный разбирает сработавшие правила. CX Codex +1 3 600установок log-analysis aj-geddes Скилл для разбора логов приложений и систем: находит ошибки, повторяющиеся паттерны и первопричину сбоя. Пригодится, когда надо разобраться, почему падает сервис. CX Codex +1 657установок twilio-notifications-alerts-advisor официальный Twilio Помогает выбрать архитектуру транзакционных уведомлений: канал, срочность, подтверждение доставки и запасные варианты. CX Codex GP ChatGPT ★ 7 596звёзд репо cargo-observability getcargo Настраивает фоновые проверки воркспейса Cargo и запускает действия агента при сбоях. Пригодится для контроля ошибок в пайплайнах и свежести данных. CX Codex +1 6 200установок dt-obs-log-semantic-mapping Dynatrace Скилл сопоставляет поля аудит-логов вендора с семантическим словарём Dynatrace и проверяет готовую схему. CX Codex +1 1 400установок loki grafana Скилл loki от Grafana учит агента писать запросы LogQL и настраивать сбор логов в Loki. Внутри — синтаксис селекторов, парсеров и метрик, архитектура и приём логов через Alloy, Promtail и Fluent Bit. CX Codex +1 7 500установок

Из того же набора21

exploring-live-traffic Скилл учит агента читать вкладку Live в PostHog Web analytics: кто на сайте прямо сейчас, какие боты стучатся и куда идут люди. CX Codex +1 378установок finding-replay-for-issue Находит среди сессий, привязанных к ошибке в PostHog, ту запись, по которой видно, что пользователь делал до сбоя. CX Codex +1 375установок suggesting-data-imports Подсказывает, каких данных не хватает в PostHog, и ведёт к подключению источника в дата-вейрхаусе. Пригодится, когда запрос падает из-за отсутствующей таблицы. CX Codex +1 372установок inbox-exploration Скилл для работы с PostHog Inbox: показывает отчёты, помогает разобрать их и превратить в задачу или PR. CX Codex +1 370установок formatting-insight-axes Подбирает правильную единицу оси Y при создании инсайта в PostHog: секунды, миллисекунды, проценты, валюта. Избавляет от формул ради пересчёта единиц. CX Codex +1 353установок triaging-error-issues Собирает короткий список ошибок PostHog, на которые стоит смотреть: новые, всплески и те, что задели много пользователей. Пригодится на утреннем или дежурном разборе. CX Codex +1 329установок signals-scout-general Скилл для PostHog: ищет корреляции между продуктами и заглядывает туда, куда не смотрят узкие скауты. Пишет отчёт в инбокс. CX Codex +1 314установок designing-email-templates Скилл создаёт и редактирует шаблоны писем для кампаний и рабочих процессов PostHog через MCP. Пригодится, когда письмо нужно собрать из редактируемых блоков и персонализировать с помощью Liquid. CX Codex +1 301установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой