> ## 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.

# Health & alerts

> Check your app's lag and pod health, and configure alerts to your team's chat channel.

Once your app is registered, Sariva can report its health and alert your team when something drifts.

> [!NOTE]
>
> `<your-token>` in the examples below is a platform API key — in this release that means your **platform operator's** key, not a team key. See [Getting a token](https://sariva.mintlify.site/app-teams/register.md#getting-a-token).

## Check health on demand

```bash theme={null}
curl https://<platform-url>/api/v1/apps/payments-consumer/health \
  -H "Authorization: Bearer <your-token>"
```

Returns the app's **pod status** (Kubernetes only — `NotApplicable` on a VM), its most recent alert (`last_alert`), and `alert_lifecycle` — for each alert type that has ever fired, whether it is `active` or `clear`, `active_since`, `last_fired_at` and `last_cleared_at`. An `active` entry makes the app `degraded` (warning) or `unhealthy` (critical) regardless of how long ago the alert posted. Pod status comes from the cluster Sariva is configured to read; lag reaches this route as the alert engine's lag alert, not as a live read.

The route never reads the app's logs — CloudWatch or New Relic — and says so: `"logs": "not_read"`. For errors from the logs, ask Sariva in chat (the app's on-demand log scans must be approved).

## Producer health

A producer has no consumer lag, so Sariva judges it from what proves it is running. Chat and *"is everything healthy?"* read its logs (where approved) and give the same verdict, on a VM and on Kubernetes. `GET /api/v1/apps/{alias}/health` reads no logs — see [Over REST](#over-rest).

| Signal | What it shows |
| - | - |
| A log line in the last 5 minutes | the process is running. An older line proves nothing about now: with no pod signal the verdict is **unknown**, and Sariva says when the last line was and whether messages reached its topic since |
| Pod state (Kubernetes only) | a pod that isn't running is a problem; a running pod counts as running |
| Error lines | a problem, with sample lines. Sariva names authentication failures, topic authorization failures, records over the size limit and unreachable brokers (librdkafka and Java wording) |
| Messages it sent | activity, not health: the producer's own logged send count when its lines carry one (`sent 120 messages`), else the messages on its topics |

| Verdict | Meaning | `status` |
| - | - | - |
| healthy | running, no errors, sent messages | `healthy` |
| healthy, idle | running, no errors, sent nothing — normal when there were no events | `healthy` |
| warning | idle for longer than `expect_messages_within` | `degraded` |
| problem | error lines, or its pod isn't running | `unhealthy` |
| unknown | no log line in the last 5 minutes and no pod signal — Sariva states what it saw (the last line's time, the messages on its topic since) and doesn't guess whether it is running or down; or its logs couldn't be read | `unknown` |

Logs are read only when the app's on-demand chat scans are approved, and each read counts toward its daily chat limit. Otherwise the verdict says why it can't tell.

### Over REST

`GET /api/v1/apps/{alias}/health` never reads logs (`"logs": "not_read"`), so errors aren't checked. On Kubernetes a running pod shows the producer runs and the messages on its topics show its activity: **healthy**, **healthy, idle** or **warning**, as above. On a VM there is no pod, and messages on a topic may come from another producer, so the verdict is **unknown**. In both, `status` takes the worse of the verdict and any active alert. The response carries the verdict in `verdict`, `verdict_label` and `fact`, and the readings in `producer`.

## Configure alerts

Set alert preferences at registration or update them later with `PUT /api/v1/apps/{alias}`. Alerts post to the channel the app registered on your install's chat surface — its `teams_channel_id` on a Teams install, its `slack_channel` on a Slack install ([Register an application](https://sariva.mintlify.site/app-teams/register.md#the-fields)).

| Preference | Type | Fires when |
| - | - | - |
| `chat_alerts` | bool | Master switch for this app's chat alerts — `false` mutes them on every surface (default `true`) |
| `alert_on_lag_above` | int | Lag exceeds this absolute value (e.g. `10000`) |
| `alert_on_lag_increasing_pct` | int | Lag grows by this % over a 5-minute window (e.g. `20`) |
| `alert_on_pod_restart` | bool | A pod for this app restarts |
| `alert_on_consumer_rebalance` | bool | The consumer group rebalances |
| `alert_on_error_pattern` | list | A matching pattern appears in logs (e.g. `["ERROR","timeout"]`) |
| `alert_cooldown_minutes` | int | Quiet window before an event-style alert (pod restart, rebalance, lag growth) counts as over (default `15`). Unchanged conditions never repeat, so this is not a repeat interval. |

```bash theme={null}
curl -X PUT https://<platform-url>/api/v1/apps/payments-consumer \
  -H "Authorization: Bearer <your-token>" -H "Content-Type: application/json" \
  -d '{ "alert_on_lag_above": 10000, "alert_on_pod_restart": true, "alert_cooldown_minutes": 15 }'
```

> [!NOTE]
>
> **Pod-level alerts need pod coordinates.** `alert_on_pod_restart` and `alert_on_consumer_rebalance` require `eks_cluster_name`, `k8s_namespace`, and `k8s_pod_label_selector` on the app (e.g. `app=payments-consumer`). `alert_on_error_pattern` requires `cloudwatch_log_group`. Lag alerts need none of these — they work from the Metrics API alone.

Sariva polls registered apps on a fixed cadence (60 s) and posts **once per episode**: the alert when a condition crosses, a re-fire only if it gets materially worse (severity escalates or the number at least doubles), and a single ✅ recovery once the condition has been clear for two consecutive checks. A problem that just sits there posts nothing further, however long it lasts. The full rules, including how event-style alerts and the 5-minute error-pattern window behave, are on [Alerting](https://sariva.mintlify.site/concepts/alerting.md#the-alert-lifecycle).


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