> ## Documentation Index
> Fetch the complete documentation index at: https://sariva.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Alerting

> How Sariva watches your clusters and apps, decides when to ping you, and what you can tune.

Sariva runs two alerting loops, each on a **60-second** cycle. Both **poll** — they reach out and check on a cadence; nothing depends on an inbound push or webhook.

* **Per-app alerting** — lag, error patterns, pod restarts and rebalances for each **registered app**. **Developer-facing** — each alert goes to the app's channel on the install's chat surface: its Teams channel on a Teams install, its Slack channel on a Slack install. The same loop also probes every registered cluster and posts **cluster unreachable / recovered** to the SRE channel — chat only, never paged.
* **Cluster-infra alerting** — the Confluent Platform pods of every registered CFK-on-EKS cluster (every pod in the cluster's CFK namespace: brokers, KRaft, Schema Registry, Connect, ksqlDB, REST Proxy). A container **OOMKilled** pages; sustained high **CPU** posts to chat only. **SRE-facing** — goes to the SRE channel.

The **SRE channel** is the install's org-level alerts channel: the Slack alerts channel set at install (`notifications.slack.alerts_channel`) on a Slack install, the Teams alerts channel (`TEAMS_ALERTS_CHANNEL_ID`) on a Teams install.

```mermaid theme={null}
flowchart LR
  subgraph loop["every 60s (poll)"]
    direction TB
    A["Per-app engine"] --> a1["lag · error patterns · pod restarts · rebalances"]
    A --> a2["cluster reachability"]
    B["Cluster-infra engine (CFK on EKS)"] --> b1["pod OOMKilled"]
    B --> b2["pod CPU"]
  end
  a1 --> dev["App team channel (Slack or Teams)"]
  a2 --> sre["SRE channel (Slack or Teams)"]
  b1 --> sre
  b2 --> sre
  a1 -.optional.-> pd["Paging provider (PagerDuty or xMatters)"]
  b1 -.optional.-> pd
```

## How the per-app engine works

Each tick (every **60s**) the engine loads every registered app and evaluates only the conditions that app **opted into**:

| Condition | Fires when |
| - | - |
| `alert_on_lag_above` | Consumer-group lag exceeds an absolute threshold |
| `alert_on_lag_increasing_pct` | Lag grows more than N% over \~5 minutes |
| `alert_on_error_pattern` | A pattern appears in the app's logs (CloudWatch Logs or New Relic — the install's one log source), **once a platform SRE has approved scanning for that app** — see [App logs & pod health](https://sariva.mintlify.site/app-teams/logs-and-pod-health.md) |
| `alert_on_pod_restart` | An app pod's restart count increases |
| `alert_on_consumer_rebalance` | The consumer group rebalances |

Three rules keep it useful instead of noisy:

* **Opt-in only.** Nothing fires unless the developer asked for it — no firehose of every Kafka event.
* **One alert per episode.** Each alert type per app is either *clear* or *active*. You hear about a condition when it crosses the threshold, again only if it gets materially worse, and once more when it is over. A condition that simply stays true posts **nothing** — not after the cooldown, not ever.
* **One recovery per episode.** When the condition has been observed clear for two consecutive checks, Sariva posts a single two-line recovery (what cleared and the value it cleared at), resolves the page it opened (with the provider that accepted it), and goes quiet.

### The alert lifecycle

| Transition | When | What you see |
| - | - | - |
| clear → active | the condition crosses the threshold | the alert |
| active → active | still true, not worse | nothing, however long it lasts |
| active → active | **worse**: severity escalated (warning → critical), or the number at least **doubled** since the last post | a re-fire; the bar resets to the new value |
| active → clear | observed clear for **2 consecutive checks** (one check is noise) | one ✅ recovery, then silence |

Flapping — over, under, over again before the second clear check — posts the alert once and no recovery. A check that returns no reading (the Metrics API or CloudWatch was unreachable) is not a clear check: Sariva never announces a recovery for a consumer that merely lost its metrics. The state is persisted, so a platform restart neither re-fires an active alert nor forgets to post its recovery.

**Event-style alerts clear more slowly.** `alert_on_pod_restart`, `alert_on_consumer_rebalance` and `alert_on_lag_increasing_pct` fire on a *change between two checks* rather than a level, so they are naturally "clear" on the very next quiet check. For these, "over" means a full `alert_cooldown_minutes` window with no new events (15 quiet checks at the defaults) — a crash-looping pod is one alert and one recovery, not a pair every backoff cycle. A repeat of the same event while active (one more restart of the same pod) is not "worse"; two pods restarting at once is.

**Error patterns lag reality a little.** `alert_on_error_pattern` is read on the interval the SRE approved (every 5 minutes by default; 1, 5 or 15) over a window of the same length, so the count stays flat for up to one interval after the last matching line; at the default the recovery arrives about seven minutes after the errors actually stop (plus the log provider's ingestion delay). A flat count never re-fires.

**Log scanning is approved and capped per app.** Registering an app with patterns and a log location posts **one** request for scheduled monitoring to the SRE channel (the app, its patterns, the interval, an honest estimate and a suggested cap); the engine reads that app's logs only after an SRE replies **approve** in the post's thread — *deny* keeps it off, *approve, every 15 min, cap 50* sets the interval (1, 5 or 15) and the cap (GB per month on CloudWatch, queries per day on New Relic). At 80% of its cap the app's chat thread is warned; at 100% that app's monitoring **pauses** (the thread and the SRE channel are told) and resumes next period by itself. On-demand chat reads of the same app are a **separate** approval with a look-back and a daily limit. An optional install-wide `LOG_SCAN_BUDGET` pauses every app at 100% on top; an install with no log source scans nothing and says so. Details: [App logs & pod health](https://sariva.mintlify.site/app-teams/logs-and-pod-health.md#approval--your-platform-team-switches-scanning-on).

**What an alert shows.** In Slack: the severity and the title, which names the condition and its number; a plain-language **Likely issue** line when Sariva can map one; and a line naming the team, cluster and consumer group. The Teams alert carries the same content. For the evidence behind it, ask Sariva about the app in chat — see [Ask Sariva about your app](https://sariva.mintlify.site/app-teams/ask-sariva.md).

Optionally an alert also **pages** your configured provider — PagerDuty or xMatters, one per install — under a correlation key per app + alert type (the page carries **your** runbook URL for the app — the registration's `runbook_url` field — when one is set, never Sariva's internal knowledge-base path; the chat alert shows only a plain-language "Likely issue" line and never a URL); the recovery **resolves** that page. A re-fire reuses the same key: PagerDuty folds it into the open incident, so a second incident is never opened for the same episode; xMatters does the same only if your flow has the [re-fire dedup branch](https://sariva.mintlify.site/prerequisites/paging/xmatters.md#re-fire-dedup-on-the-trigger-path--proven-on-2026-10-16) — without it, each re-fire creates a new xMatters alert. A resolve the provider did not accept is retried on later checks (up to 10 attempts) and then logged as abandoned — the chat recovery still posts exactly once. A trigger the provider did not accept (including a rate-limit `429`) is not retried: the chat alert still posts, but that episode has no page to resolve.

**Cluster reachability.** The same loop probes every registered cluster. After **3** consecutive failed probes it posts **UNREACHABLE** to the SRE channel once; the first successful probe after that posts **RECOVERED**. Chat only — never paged.

## How the cluster-infra engine works

Each tick (every **60s**) the engine lists the pods in each eligible cluster's CFK namespace and checks two signals:

| Signal | Fires when | What you get |
| - | - | - |
| **OOMKilled** | A container's last (or current) termination reason is `OOMKilled` and the kill is newer than the last one Sariva recorded for that pod | SRE channel + **page**, severity critical — for every CFK component |
| **CPU** | A pod's CPU stays at or above **90%** of its limit for **5** consecutive checks | SRE channel only, severity warning — never paged. While it stays high it posts again at most once per 15 minutes; there is no recovery post |

**OOMKilled is an event, keyed on the kill's time.** Each new kill alerts once — never again on a later check, after a Sariva restart, or after the episode has cleared. A kill Sariva first sees more than an hour after it happened is recorded silently as a baseline. A further kill while the alert is open posts a chat update (at most one per 15 minutes) and never opens a second page. The alert clears after **15 consecutive clean reads** — the pod Running with every container Ready and no new kill. A pod that is gone (scale-down) counts as a clean read, so it too closes after 15 reads, not instantly. Then Sariva posts one recovery and resolves the page with the provider that accepted it. A failed pods read is not a clean read, so a page never closes on missing data.

**There is no memory-percentage alert.** Kafka pods normally sit at 90-95% memory because Linux uses free memory as page cache — that is not pressure, and alerting on it paged people for healthy brokers. The OOM kill is the signal that matters.

**CPU needs metrics-server.** If the cluster has no metrics-server (HTTP 404), or Sariva's reader role lacks the `metrics.k8s.io` grant (HTTP 403), Sariva posts one "CPU alerting off" notice for that cluster and skips CPU until metrics reads succeed again. OOMKilled detection reads the pods list only and keeps working.

## What each audience gets

* **App developers** — scoped, actionable alerts about *their* app in *their* channel on the install's chat surface ("Lag exceeded threshold on payments-consumer: lag 47,210 > threshold 10,000 as of 14:05 UTC" — the minute Confluent's metric is of, which runs 1-3 minutes behind the broker; in chat Sariva reads the lag live and says "read just now"), configured per app at [registration](https://sariva.mintlify.site/app-teams/register.md) or via [Health & alerts](https://sariva.mintlify.site/app-teams/health-and-alerts.md).
* **SREs** — platform-level signals (cluster unreachable / recovered, CFK pod OOMKilled, sustained CFK pod CPU) in the SRE channel, without per-app noise — and everything is queryable on demand in chat.

## Configure it

* **Per-app conditions & cooldown** — at registration, or later via `PUT /api/v1/apps/{alias}` ([Health & alerts](https://sariva.mintlify.site/app-teams/health-and-alerts.md)). `alert_cooldown_minutes` no longer governs repeats of an unchanged condition (those never repeat); it sets how long an event-style alert must stay quiet before it is considered over.
* **Current state** — `GET /api/v1/apps/{alias}/health` returns `alert_lifecycle`: per alert type, `active` or `clear`, since when, and when it last cleared.
* **Where app alerts go** — the app's destination field for the install's chat surface: `teams_channel_id` on a Teams install, `slack_channel` on a Slack install; nowhere in chat when it registered with `chat_alerts: false` (paging is unaffected) ([Register an app](https://sariva.mintlify.site/app-teams/register.md)).
* **Where cluster alerts go** — the SRE channel: the Slack alerts channel set at install (`notifications.slack.alerts_channel`) on a Slack install, the org-level Teams alerts channel (`TEAMS_ALERTS_CHANNEL_ID`) on a Teams install ([Point Sariva at the alerts channel](https://sariva.mintlify.site/prerequisites/teams/install-app.md#point-sariva-at-the-alerts-channel)).
* **Paging** — optional, one provider per install, wired at install ([PagerDuty](https://sariva.mintlify.site/prerequisites/paging/pagerduty.md) · [xMatters](https://sariva.mintlify.site/prerequisites/paging/xmatters.md)).
* **Log source and budget** — one source per install (CloudWatch Logs, [New Relic](https://sariva.mintlify.site/prerequisites/log-sources/newrelic.md) or none) and an optional install-wide budget, chosen in the wizard's last step; the two per-app approvals and their caps happen in the SRE channel. Usage for the period: `GET /api/v1/health` (`log_scanning`) and `sariva validate logs`.
* **Loop frequency** — 60 seconds for both engines; not configurable in this release.
* **Cluster-infra thresholds** — fixed in this release: CPU at 90% of its limit for 5 checks; an OOMKilled alert clears after 15 clean reads.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.