# Send alerts to a webhook or GitHub Discussions

> Configure a receiver so OpenLakeForge notifies you when a pipeline run fails, a scheduled run never starts, output goes stale or a quality check fails. It…

Source: https://openlakeforge.dev/docs/guides/operations/alerts/

Configure a receiver so OpenLakeForge notifies you when a pipeline run fails, a
scheduled run never starts, output goes stale or a quality check fails. It
covers the two receiver types, the alert policy that says which products alert
and who is told, what a notification contains, and what to do for each
condition.

| Receiver type | Where alerts go | Set it up |
| --- | --- | --- |
| `webhook` | An HTTPS endpoint that accepts a JSON `POST`: Slack, an incident tool, your own service. | [Configure a receiver](#configure-a-receiver) |
| `github-discussions` | A discussion in a GitHub repository, posted by the OpenLakeForge GitHub App. Watching the repository emails you or notifies the GitHub mobile app. | [Send alerts to GitHub Discussions](#send-alerts-to-github-discussions) |

`olf infra alerts test <receiver>` sends one test notification to either type
before a real alert depends on it ([Check it](#check-it)).

An alert evaluator runs every 5 minutes as a CronJob in `olf-system`, on the
local provider. It reads each enabled stage's Dagster and its quality
manifests, keeps its state in the ops bucket under `alerts/`, and posts to your
receivers. It needs no Prometheus, Loki or Grafana, and it exists only when
the profile declares at least one receiver. The design is
[ADR 0023](https://openlakeforge.dev/docs/adr/0023-alert-evaluation-and-webhook-delivery/).

:::caution
**Product alerts are silent unless `lakehouse_code/alerts.yml` declares
them.** A project without that file gets only the platform alerts
([`stage_unreadable`](#stage_unreadable), [`policy_unreadable`](#policy_unreadable),
[`service_degraded`](#service_degraded) and
[`health_unreadable`](#health_unreadable)). Before the policy existed, every
product's conditions alerted. If you deployed receivers from such a build,
upgrade like this:

1. Add `lakehouse_code/alerts.yml`. A project made by `olf init` carries the
   sample one; an existing project, and one made with `olf init --empty`,
   does not. [Write the policy](#write-the-alert-policy) or copy the sample's.
2. Run `olf check contracts`, then `olf alert explain` for a product (or a
   job) and a stage to see what will alert.
3. Build a revision and deploy it to each stage
   ([promote DEV to PROD](https://openlakeforge.dev/docs/guides/promote-dev-to-prod/)). The evaluator reads the
   policy of the stage's active revision, and activation fails when a route
   names a receiver that `openlakeforge.yaml` does not declare.

The first evaluation after the upgrade resolves, without a notification,
every firing product incident that no rule covers.
:::

## Configure a receiver

These steps set up a `webhook` receiver; a GitHub Discussions receiver needs no
URL, see [its own section](#send-alerts-to-github-discussions).

1. Declare the receiver in `openlakeforge.yaml`:

   ```yaml
   spec:
     observability:
       alerts:
         receivers:
           - name: on-call
             type: webhook
             stages: [prod]
             secret_ref:
               name: alert-webhooks
               key: webhook-url
   ```

2. On a first deploy, run `olf infra deploy -f openlakeforge.yaml` now. It creates
   `olf-system`, then stops at the missing Secret and names
   `olf infra alerts bind`. `bind` never creates the namespace and fails when it
   is absent. On a stack that is already deployed, go straight to the next step.

3. Bind its URL into the Secret in `olf-system`. The URL is the receiver's
   credential: `olf` reads it from an environment variable or a file (or asks
   for it, without echo, in a terminal), never from the command line, and
   Terraform never holds its value. It must be an `https://` URL:

   ```bash
   export WEBHOOK_URL='https://hooks.example.com/services/...'
   olf infra alerts bind on-call -f openlakeforge.yaml --from-env WEBHOOK_URL
   olf infra alerts bindings -f openlakeforge.yaml
   ```

   `bind` writes only that receiver's key, so receivers that share a Secret
   keep each other's keys. It prints the receiver, Secret and key, never the
   URL; `--dry-run` shows what it would change. `bindings` reports each
   receiver as bound, Secret missing or key missing, and exits 1 unless all are
   bound. Creating the Secret another way works too.

4. Validate and deploy (again, on a first deploy):

   ```bash
   olf profile validate --project .
   olf infra platform apply -f openlakeforge.yaml
   ```

The deploy fails, naming the receiver, when the Secret or the key is missing.
To change the URL, run `olf infra alerts bind` again; the next evaluation reads it.

| Field | Meaning |
| --- | --- |
| `name` | Names the receiver in logs and history. The URL never appears there. |
| `type` | `webhook`, an HTTPS endpoint that accepts a JSON `POST`, or `github-discussions`. |
| `secret_ref` | `webhook` only: the Secret and key that hold the URL. |
| `stages` | Optional. The stages this receiver hears about, for example `[prod]` to keep DEV quiet. Omitted means every enabled stage. It is a ceiling: a rule in `alerts.yml` cannot send a stage's alerts to a receiver that leaves that stage out. |

The field reference is in the
[deployment profile](https://openlakeforge.dev/docs/reference/deployment-profile/#specobservability).

### Platform receivers

Platform conditions are not product alerts, so `alerts.yml` cannot route them.
The profile does, with `platform_receivers`:

```yaml
spec:
  observability:
    alerts:
      receivers:
        - name: on-call
          type: webhook
          secret_ref: {name: alert-webhooks, key: webhook-url}
        - name: sales-webhook
          type: webhook
          secret_ref: {name: alert-webhooks, key: sales-url}
      platform_receivers: [on-call]
```

Omitted, every receiver gets the platform conditions. A list that is present
must be non-empty, name declared receivers and repeat none; an empty list is a
validation error, because it would silence every platform condition. Omit the
field to say "all". A receiver's `stages` still applies, so a `prod`-only
receiver never hears about `dev`. `olf profile resolve --project . --json`
shows the effective list as `observability.alerts.platform_receivers`.

### Delivery

- The URL must be `https`. A redirect is a rejected delivery and is not
  followed.
- A connection failure, a timeout, `408`, `429` or a `5xx` response is
  retried up to 3 times in one evaluation, then left queued for the next
  evaluations, and given up after 12 (about an hour), when it is recorded as
  `undeliverable`. Each attempt waits at most 5 seconds to connect and 10 to
  read. Between attempts the evaluator waits an exponential backoff with jitter
  (0.5 second base, 4 second cap), or the receiver's `Retry-After` when longer,
  capped at 10 seconds. It saves its state after every attempt and starts no
  new send after 150 seconds, inside the CronJob's 240 second deadline, so a
  slow receiver cannot stop progress being recorded.
- Any other `4xx` response (for example `400`, `401`, `403` or `404`) is a
  rejection: it is recorded and never resent. Fixing the receiver afterwards
  does not recover that notification, and with no reminders the incident's
  next notification is its `resolved` or `escalated`.
- Delivery is at-least-once. Every attempt of one notification carries the same
  `Idempotency-Key: <incident_id>:<event>` header, so a receiver can drop
  repeats.
- There are no reminders and no acknowledgement. An incident notifies once
  when it opens and once when it resolves; a warning that becomes critical
  sends one `escalated`.

`GET /api/v1/stages/{stage}/alerts/incidents` on the platform API lists a
stage's open incidents, read-only, for `data-engineer` and above. Each carries
`runbook`, the [runbook section](#what-to-do-for-each-condition) of its
condition as its notification links it (`null` where the deployment sets no
runbook page), and its latest notification's `delivery`:

| `status` | Meaning |
| --- | --- |
| `pending` | Queued: not every receiver routed to it has it yet |
| `delivered` | A receiver routed to it accepted it, and none rejected it |
| `undeliverable` | It was given up after 12 evaluations, or a receiver rejected it |
| `unrouted` | No receiver was, or still is, routed to it, so nobody was told: its receivers may have been removed from the routes while it was retried |
| `unknown` | It left the queue before the evaluator kept outcomes |

`delivery.targets` lists each receiver of that notification by its name in
`openlakeforge.yaml`, with its own `status` (`delivered`, `rejected`,
`retrying` or `expired`), its `attempts`, and `url`, where the notification
landed when the receiver has a page for it: the discussion, for a
`github-discussions` receiver. The Portal's Monitoring page shows one line per
receiver and links the discussion. `targets` is `null` for a notification
settled before 0.7.0-beta.2.

The answer's `state` is `not_provided` without an evaluator or the API's key
to read its state, and
`unavailable` with `incidents: null` when the state cannot be read or the
evaluator has not written one yet. `stale: true` means the last evaluation is
more than 10 minutes old, so the list may be out of date. A webhook's URL and
headers never appear in the answer.

## Send alerts to GitHub Discussions

A `github-discussions` receiver posts each notification as a discussion in a
GitHub repository, as the OpenLakeForge GitHub App. It needs no webhook URL and
no `olf infra alerts bind`. Anyone who watches the repository is notified by
email or the GitHub mobile app. An incident's later events (`escalated`,
`resolved`) are added to its discussion as comments, and `resolved` closes it.
Incidents opened by the same run, such as a blocking quality check and the run
it failed, share one discussion, which closes once every one of them has
resolved. A post opens with one sentence (severity, product, stage and what
happened), then when, then links to the incident in the Portal, the Dagster run
and the runbook; the raw fields are folded under **Details**.

:::note
Use a private repository. A public one shows alert titles and summaries
(stage, product and condition names) to anyone who can read it.
:::

1. Create a private repository for alerts, for example `my-org/olf-alerts`.
   In **Settings**, then **General**, then **Features**, turn on Discussions.
   Under **Discussions**, create a category such as `Alerts`. Use an open
   category: an Announcement category may refuse posts from an App.

2. Install the OpenLakeForge GitHub App on that repository: on all of the
   organization's repositories, or add the repository to the selected ones.
   The receiver posts with the App that [Connect GitHub](https://openlakeforge.dev/docs/guides/identity/connect-github/)
   registers, so the profile must set `spec.identity.issuer: github`. The App
   needs the `Discussions: write` permission. An App created before
   0.7.0-beta.2 lacks it: add the permission in the App's settings, and an
   organization owner must accept the request.

3. Declare the receiver in `openlakeforge.yaml`, next to the identity block
   from that guide. To keep DEV and PROD apart, declare one receiver per stage
   and point each at its own category, for example `Alerts (prod)` and
   `Alerts (dev)`:

   ```yaml
   spec:
     observability:
       alerts:
         receivers:
           - name: alerts-prod
             type: github-discussions
             repository: my-org/olf-alerts
             category: Alerts (prod)
             stages: [prod]
           - name: alerts-dev
             type: github-discussions
             repository: my-org/olf-alerts
             category: Alerts (dev)
             stages: [dev]
   ```

   `category` matches a category's name or its slug, ignoring case. Leave out
   `stages` to send every stage to one category. Route products to these
   receivers in [`alerts.yml`](#write-the-alert-policy), like any receiver.

4. Deploy, then send a test:

   ```bash
   olf profile validate --project .
   olf infra platform apply -f openlakeforge.yaml
   olf infra alerts test alerts-prod -f openlakeforge.yaml
   ```

   The test opens a discussion titled `[test] OpenLakeForge alert test` and
   closes it at once, and the command prints what GitHub answered. It exits 0
   only when the discussion was posted. With no `--stage`, the test names the
   first enabled stage the receiver hears about; `--stage` picks another one
   from the receiver's `stages`.

5. Watch the repository to be notified: on GitHub, **Watch**, then **Custom**,
   then **Discussions**. The GitHub mobile app delivers the same notifications.

The test names the cause when GitHub refuses it. Each row is a line of the
command's output and what fixes it:

| The output says | Fix |
| --- | --- |
| `the GitHub App is not installed on <owner>/<name>` | Install the App on the repository (step 2). |
| `the GitHub App installation no longer exists` | The App was uninstalled; install it again. |
| `category '<name>' not found in <owner>/<name>` | Create the category, or correct `category` in the profile and deploy again. |
| `the GitHub App lacks discussions: write on <owner>/<name>`, or `cannot be granted discussions: write` | Add `Discussions: write` to the App's permissions, and have an organization owner accept the request (step 2). |
| `Discussions are not enabled on <owner>/<name>` | Turn on Discussions in the repository's settings (step 1). |
| `repository <owner>/<name> was not found, or the GitHub App cannot see it` | Correct `repository`, or add the repository to the App's installation. |
| `the GitHub App private key is not a usable RSA key`, or `GitHub rejected the App credentials` | The App's Secret holds a wrong id or key. Replace it with [`olf infra secrets rotate github-app`](https://openlakeforge.dev/docs/guides/identity/rotate-secrets/#the-github-app). |
| `could not reach the GitHub API`, and `retryable` | The evaluator could not reach the GitHub API. Check the cluster's egress and CA bundle. |

A webhook that filters on `event` sees a value it has not seen before:
`olf infra alerts test` sends `event: test` in a body with the same schema as any
notification (`incident_id` is `test-<UTC time>`), under the `Idempotency-Key`
`<incident_id>:test`.

## Write the alert policy

`lakehouse_code/alerts.yml` says which conditions alert for which products and
stages, with which thresholds, and which receivers hear about each. It is
optional and silent by default: a product, stage or condition that no rule
names does not alert. The profile still owns the receivers and their Secrets; a
policy only names them. Every key, type and default is in the
[alert policy reference](https://openlakeforge.dev/docs/reference/alert-policy/).

The file travels in the project revision, so each stage is judged by the policy
of its active revision and a change reaches a stage when you deploy a revision
to it. `olf check contracts` validates it offline, including that every
`match` names a domain and product of `governance.yml`.

```yaml
apiVersion: openlakeforge.io/v1beta1
kind: AlertPolicy

routes:
  on-call: on-call # route name: receiver name in openlakeforge.yaml
  sales: sales-webhook

defaults:
  stages: [prod]
  notify: [on-call]

rules:
  # Every job in PROD, maintenance jobs included.
  - match: {domain: "*", product: "*"}
    when:
      run_failed: {}
      missed_run: {}
      freshness: {}
      schedule_mismatch: {}
      sla: {}
      quality: {level: error}

  # The sales domain hears its own quality warnings; the pager does not.
  - match: {domain: sales, product: "*"}
    notify: [sales]
    when:
      quality: {level: warn}

  # One product with a business bound and a slower queue.
  - match: {domain: sales, product: order_revenue}
    notify: [sales, on-call]
    when:
      freshness: {warn_after: 26h, critical_after: 30h}
      missed_run: {grace: 30m}

  # A product still being built: no freshness alert yet.
  - match: {domain: supply_chain, product: inventory_reliability}
    when:
      freshness: false
```

- **`routes`** maps a route name to a receiver name of `openlakeforge.yaml`.
  Rules refer to routes, never to receivers or URLs.
- **`defaults`** holds the `stages` and `notify` a rule uses when it names none.
  Without `defaults.stages` a rule applies to every stage; a rule that ends up
  with no route is a validation error.
- **`match`** names a `domain` and a `product` from `governance.yml`, or `"*"`
  for either. A job that belongs to no product, such as `gold_maintenance`, is
  matched only by a rule whose `domain` and `product` are both `"*"`.
- **`when`** lists conditions. `{}` turns a condition on with its defaults and
  `false` turns it off.

### Which rule wins

For each stage and condition, the most specific matching rule wins: one that
names a product, then one that names a domain with `product: "*"`, then the
global `"*"`/`"*"`. The choice is per condition, so the `order_revenue` rule
above sets only `freshness` and `missed_run` and still takes `run_failed` from
the global rule. A `false` wins like any other value, which is how a product
opts out of a condition a broader rule turns on.

`notify` belongs to the winning rule alone, not to the union of every rule that
matches. To add `on-call` to a more specific rule, list it there too, as the
`order_revenue` rule does. Two rules of the same specificity that set the same
condition for an overlapping stage are a validation error, never settled by
file order:

```text
alerts.yml: rules[0] and rules[2] have the same specificity and both set ['run_failed'] for stage(s) ['prod']; make one more specific or split their stages
```

### See what a product or a job gets

`olf alert explain` prints, for one product or one job in one stage, the rule
that wins for each condition, its options and the routes it notifies. It reads
`alerts.yml` and `governance.yml` and needs no cluster or credential:

```bash
olf alert explain --stage prod --product order_revenue
```

```text
order_revenue (domain sales, job order_revenue_pipeline) in prod
  run_failed: severity=critical; rules[0] (*/*); notifies on-call -> on-call
  missed_run: grace=30m, severity=critical; rules[2] (sales/order_revenue); notifies sales -> sales-webhook, on-call -> on-call
  freshness: warn_after=26h, critical_after=30h; rules[2] (sales/order_revenue); notifies sales -> sales-webhook, on-call -> on-call
  quality: level=warn; rules[1] (sales/*); notifies sales -> sales-webhook
  schedule_mismatch: severity=warning; rules[0] (*/*); notifies on-call -> on-call
```

A job of no product, such as `gold_maintenance`, takes `--job` in place of
`--product`. It resolves as the evaluator resolves it: by the global rules
alone, those whose `match` is `{domain: "*", product: "*"}`. A job named
`<product>_pipeline` resolves as that product:

```bash
olf alert explain --stage prod --job gold_maintenance
```

```text
job gold_maintenance (no product: global rules only) in prod
  run_failed: severity=critical; rules[0] (*/*); notifies on-call -> on-call
  missed_run: grace=15m, severity=critical; rules[0] (*/*); notifies on-call -> on-call
  freshness: grace=15m, severity=critical; rules[0] (*/*); notifies on-call -> on-call
  quality: level=error; rules[0] (*/*); notifies on-call -> on-call
  schedule_mismatch: severity=warning; rules[0] (*/*); notifies on-call -> on-call
```

`olf` reads no cluster, so it does not check that the job exists.

A condition no rule names prints `not declared, does not alert`, and one a rule
turned off prints `off by` that rule. `--project` selects another project root.

| Exit | Meaning |
| --- | --- |
| `0` | The policy was read, including a project with no `alerts.yml`, which prints that nothing alerts. |
| `1` | The project, `governance.yml` or `alerts.yml` is invalid, or the product is not in `governance.yml`. |
| `2` | The stage is not `dev`, `uat` or `prod`, or not exactly one of `--product` and `--job` is given. |

### Each condition's options

| `when` key | Options | Defaults |
| --- | --- | --- |
| `run_failed` | `severity`: `warning` or `critical` | `critical` |
| `missed_run` | `grace`: how long after a due time a run may still start; `severity` | `15m`; `critical` |
| `freshness` | Either `warn_after` and `critical_after`, or `grace` and `severity` | cadence-derived; see below |
| `quality` | `level`: `warn` or `error` | `warn` |
| `schedule_mismatch` | `severity` | `warning` |
| `sla` | `severity` | `critical` |

A duration is a positive integer with `m`, `h` or `d`: `30m`, `26h`, `2d`.

- **`missed_run`** with a `grace` of `30m` waits 30 minutes past a due time
  instead of 15 before it opens. Detection still waits for the next 5 minute
  evaluation.
- **`freshness`** opens a `stale_output` incident. With no options it uses the
  schedule's cadence: no success since the previous due time plus the grace.
  With `warn_after` or `critical_after`, it measures the age of the last
  successful run: older than `warn_after` is a `warning`, older than
  `critical_after` is `critical`, and either may be set alone. `warn_after` must
  be below `critical_after`, and the thresholds do not mix with `grace` or
  `severity` in one rule. Thresholds apply whatever the schedule's state, so DEV
  and UAT, which have no schedule, can use them.
- **`quality`** with `level: warn` alerts on a Floe warning or a non-blocking
  error at `warning` and on a blocking error at `critical`. With
  `level: error`, a warning alone does not alert. Floe and dbt keep their own
  thresholds; `level` only chooses which outcome alerts.
- **`schedule_mismatch`** applies to PROD, the only stage with schedules.
- **`sla`** opens an `sla_breach` incident when a product's declared `sla` is observed breached; see
  [Product SLA compliance](https://openlakeforge.dev/docs/reference/health-signals/#product-sla-compliance). A product that declares no
  `sla` has nothing to breach. An `unknown` observation (no run yet, an unreadable Dagster) opens nothing.

## Platform alerts

Four conditions describe the platform and not a product. `alerts.yml` cannot
name them; the schema rejects them as unknown `when` keys. They go to the
[platform receivers](#platform-receivers), capped by each receiver's `stages`,
and open and resolve under the same rules as other incidents, with no
reminders.

| Condition | Severity | Opens when |
| --- | --- | --- |
| `stage_unreadable` | `critical` | Dagster for a stage could not be read in 3 consecutive evaluations. |
| `policy_unreadable` | `warning` | A stage's alert policy cannot be used. |
| `service_degraded` | `warning` or `critical` | A platform service of a stage is degraded. One incident per stage and component. |
| `health_unreadable` | `critical` | The platform API's services route for a stage could not be read in 3 consecutive evaluations. |

`service_degraded` and `health_unreadable` need the platform API, which the
local provider deploys when the profile declares `spec.access`. Without it
the evaluator reads no service signal and raises neither.

## A notification

```json
{
  "schema": "openlakeforge.alert.v1",
  "event": "opened",
  "incident_id": "3f2a9c-1763294400-1",
  "condition": "run_failed",
  "severity": "critical",
  "stage": "prod",
  "product": "order_revenue_pipeline",
  "run_id": "8f1c2d3e-0000-4000-8000-000000000000",
  "opened_at": "2026-11-16T12:05:00+00:00",
  "event_at": "2026-11-16T12:05:00+00:00",
  "summary": "latest run failed",
  "links": {
    "portal": "https://olf.example.com/monitoring?stage=prod&incident=3d1ff9b1577ee2ce-1795690201-1",
    "run": "https://dagster-prod.olf.example.com/runs/8f1c2d3e-0000-4000-8000-000000000000"
  }
}
```

The body is built from this closed list of fields and nothing else:

| Field | Content |
| --- | --- |
| `schema` | `openlakeforge.alert.v1`. |
| `event` | `opened`, `escalated` or `resolved`; `test` only from `olf infra alerts test`. |
| `incident_id` | `<fingerprint>-<opened_at>-<seq>`; see [Incidents and state](#incidents-and-state). |
| `condition` | One of the conditions below. |
| `severity` | `warning` or `critical`. |
| `stage`, `domain`, `product`, `table` | Where it happened; absent fields are left out. |
| `run_id` | The Dagster run, when the condition has one. |
| `opened_at`, `event_at` | UTC timestamps. |
| `summary` | A fixed phrase, never log or error text. For `service_degraded` it names the component (`Dagster workloads are degraded`), which is not a field of its own. |
| `links.portal` | The incident's row on the Portal's Monitoring page, opened, behind the perimeter. |
| `links.run` | The run in the stage's Dagster, behind the perimeter: the reader signs in and needs a role for that stage. |
| `links.runbook` | The condition's section of the alert runbook: [What to do for each condition](#what-to-do-for-each-condition) at the deployed release, unless [overridden](#the-runbook-link). |

A payload never carries log lines, run tags, error text, row contents, storage
URLs or credentials. `links.portal` and `links.run` are `http` only where
`spec.access.tls` is `none`, and are left out without `spec.access`.

## Incidents and state

One evaluation reads every enabled stage, decides which incidents open, change
or resolve, and delivers what that produced. The rules below are
[ADR 0023](https://openlakeforge.dev/docs/adr/0023-alert-evaluation-and-webhook-delivery/)'s D2 and D3.

### When each condition opens and resolves

| Condition | Opens when | Default severity | Resolves when |
| --- | --- | --- | --- |
| `run_failed` | The latest run of the job failed. | `critical` | A later run succeeds. A run in progress resolves nothing. |
| `missed_run` | A running schedule is past its due time plus grace (`15m`) and no run started since. | `critical` | A run starts at or after the due time. If the schedule is stopped while it is open, it resolves without a notification. |
| `stale_output` | Cadence: no success since the previous due time plus grace. Thresholds: the last success is older than `warn_after` (`warning`) or `critical_after` (`critical`). Not while `missed_run` or `run_failed` is open for the job. | `critical` | A success at or after the due time, or younger than `warn_after`. A schedule switched on after its due time is not a recovery. |
| `quality` | The latest outcome is `warn` or a non-blocking `error` (`warning`), or a blocking `error` (`critical`). | `warning` or `critical` | A later run's outcome is `passed`. |
| `schedule_mismatch` | A PROD schedule the cadence declares running is stopped. | `warning` | The schedule or the declaration changes; without a notification. |
| `sla_breach` | A product's declared `sla` reads `breached`: its age is past `maximumAge`, a due run or `readyBy` was missed, its quality is below `minimumQualityScore`, or a product it reads is breached. | `critical` | The product reads `compliant`. Held while it reads `unknown`; closed without a notification when its schedule is stopped on purpose. |
| `stage_unreadable` | Dagster for the stage could not be read in 3 consecutive evaluations. | `critical` | The first evaluation that reads it. |
| `policy_unreadable` | The stage's alert policy cannot be used. | `warning` | The first evaluation that reads it cleanly. |
| `service_degraded` | A platform service signal is degraded; one incident per stage and component. | The signal's state for a workload, `critical` otherwise | The component reads `healthy`. |
| `health_unreadable` | The platform API's services route could not be read in 3 consecutive evaluations. | `critical` | The first evaluation that reads it. |

Nothing opens for a canceled run, a single `unknown` signal, a stopped or
absent schedule (for `missed_run` and cadence `stale_output`), or a job with no
success among the runs read. An `unknown` signal resolves nothing either, and
while a stage is unreadable its open incidents are held.

### Severity and policy changes

A severity that rises for the same incident sends one `escalated`: a `quality`
warning that becomes a blocking error, or a `stale_output` past `warn_after`
that passes `critical_after`. A fall sends nothing and is recorded as
`severity_changed`, as is a rise back to a severity already notified.

| Change to the policy while an incident is open | Effect |
| --- | --- |
| The condition is no longer declared for the job and stage (rule removed, `false`, stage dropped, `alerts.yml` removed) | It resolves without a notification (`resolved_silently`) |
| The severity rises | One `escalated` on the next evaluation |
| The severity falls | No notification; `severity_changed` in history |
| The routes change | Routes are computed at every delivery attempt: a later `resolved` goes to the routes of the rule that wins then |
| A threshold or grace changes | Applies from the next evaluation; an incident whose condition no longer holds resolves with a notification |

### Identity

An incident's fingerprint hashes the model version, stage, condition, domain,
product, table and component. It leaves out the run id, so repeated failures
are one incident, and the policy, so editing a rule never splits one. A
recurrence after a resolve is a new incident with the same fingerprint and the
id `<fingerprint>-<opened_at>-<seq>`: `opened_at` is the UTC epoch second it
opened and `seq` a per-fingerprint counter, so ids stay apart within one second
and after the state is lost.

### State objects

Everything is under the bucket-root prefix `alerts/` of the ops bucket, with the
key `openlakeforge-alerts`: `Read`, `Write` and `List` on `alerts/*`, `Read` and
`List` on each stage's quality manifests, and the policy reads of the
[alert policy reference](https://openlakeforge.dev/docs/reference/alert-policy/#how-the-evaluator-reads-the-policy).
`Write` can overwrite and delete, so history is tamper-evident against everyone
but the evaluator, not immutable.

| Object | Content |
| --- | --- |
| `alerts/state/v1/state.json` | `schema_version`, `evaluated_at`, the open incidents (fingerprint, id, severity, notified severity, `opened_at`, `last_seen`, last run, and how the latest notification left the outbox: `delivered`, `undeliverable` or `unrouted`, with receiver, acceptance and attempt counts), the per-fingerprint id counter, the per-stage count of unreadable evaluations, and the outbox of notifications not yet delivered |
| `alerts/state/v1/policy/<stage>.json` | The stage's last good alert policy |
| `alerts/history/v1/date=<YYYY-MM-DD>/<incident-id>-<seq>-<event>.json` | One object per event (`opened`, `escalated`, `severity_changed`, `resolved`, `resolved_silently`) and per delivery attempt (receiver name, attempt, HTTP status or error class, time); no body and no URL |
| `alerts/state/v1/corrupt/<UTC time>.json` | A state that failed to parse, kept for the operator |

Each evaluation reads the policies, the signals and the state; applies the
rules, appends new events to the outbox and writes `state.json`; then delivers
the outbox, recording each attempt in history. An entry leaves the outbox once
every receiver routed to it has it, or when it expires, and `state.json` is
written again. A crash between a delivery and that write sends the
notification again with the same `Idempotency-Key`. If the bucket cannot be
read or written, nothing is delivered and the Job fails.

A missing `state.json` is an empty state, and so is one that does not parse,
after it is copied to `corrupt/`. The first evaluation after either notifies
every firing incident again, under a new id and so a new `Idempotency-Key`.

`alerts/history/` expires 30 days after each record is written, whatever the
log archive's retention: the object store gives the prefix a 30-day TTL, the
same filer path TTL that expires the log archive
([ADR 0022](https://openlakeforge.dev/docs/adr/0022-pod-log-collection-and-archive-format/)). It
reaches only records written after the rule was set, so history from before it
never expires. `alerts/state/` has no TTL and is kept forever, and the
evaluator deletes nothing itself.

The evaluator's `--now <timestamp>`, `--state-prefix <prefix>` and
`--policy-file <path>` flags fix the clock, move state and history to another
prefix, and replace every stage's policy. They are for the e2e and unit tests;
the CronJob never passes them.

## What to do for each condition

This is the alert runbook. The headings are the `condition` values, which is
the anchor `links.runbook` ends with. The platform API links the same sections:
each incident from `GET /api/v1/stages/{stage}/alerts/incidents` carries
`runbook`, its condition's section, and the run quality answer
(`GET /api/v1/stages/{stage}/runs/{run_id}/quality`) links the
[`quality`](#quality) section for a run with an error check and the
[`run_failed`](#run_failed) section for any other failed run. The first five
are product conditions and alert only where `alerts.yml` declares them; the
severities below are their defaults, which a rule's options change.

Each section says first what to check in the Portal, then the command line or
API read that shows the same thing. For a product condition, start with the
stage, then the run; [Walk through a failed run](https://openlakeforge.dev/docs/guides/operations/monitoring-walkthrough/)
shows each screen:

1. Open **Monitoring** in the Portal and select the stage. **Needs attention**
   lists the open incident beside its pipeline's signal, with its latest runs
   and whether its notification went out. The **Pipelines** table gives each
   pipeline's state, latest run, last success, schedule and failed runs.
2. Select a run to open its page. **What failed** names the
   failed step and the first line of its error, and links **Open in Dagster**,
   the **Runbook** and **All runs of** the job. **Monitoring → Runs** lists the
   stage's runs by pipeline, product, status and window.
3. The run's **Logs** card reads the run's window from the log archive, after
   its pods are gone. **Open in Logs ↗** opens the same window on the **Logs**
   page, which filters by level, pod and text.
4. The run's **Quality checks** card lists the Floe and dbt checks that did not
   pass, and **What failed** links the run's retained reports.

The same reads on the command line need `olf login` and go through the
platform API:

1. `olf pipelines health <stage>` prints each pipeline's state and the reason.
2. `olf runs list --stage <stage> --job <job>` lists the job's latest runs, and
   `olf runs show <run-id> --stage <stage>` one run; `links.run` opens the same
   run in the stage's Dagster, with its steps and event log.
3. `olf logs --stage <stage> --run-id <run-id> --severity error` prints the
   run's archived pod log lines; the [log archive](https://openlakeforge.dev/docs/guides/operations/log-archive/) guide covers
   the other filters.
4. `GET /api/v1/stages/{stage}/runs/{run_id}/quality` lists the run's quality
   checks and the reports it retained.

The Portal does not start runs. To rerun a job after a fix, re-execute the run
in the stage's Dagster (**Open in Dagster**), use
`olf runs launch <job> --stage dev` on DEV, or
`olf infra product run <product> --stage <stage>` with cluster access on any
stage.

### run_failed

Critical. The latest run of a job failed. A canceled run does not alert.

- **In the Portal:** the incident's run in **Needs attention** opens the
  run's page. **What failed** gives the failed step and its error,
  the **Logs** card the run's error lines, and **Quality checks** whether a
  blocking check stopped the run.
- **On the command line:** the failed step in `links.run`, then the run's error
  lines in `olf logs`.
- **Common causes:** an error in the product's code, a source that is
  unreachable or misses a bound key (`olf infra source bindings --stage <stage>`
  lists missing keys), a blocking quality check (see [`quality`](#quality)),
  or a pod that was evicted or ran out of memory.
- **Recovery:** fix the cause and rerun. It resolves when the latest run
  succeeds; a run still in progress does not resolve it. See
  [troubleshooting](https://openlakeforge.dev/docs/guides/troubleshooting/) for pods that do not start.

### missed_run

Critical. A running schedule passed its due time plus its grace (15 minutes
unless the rule sets `grace`) and no run started.

- **In the Portal:** **Needs attention** shows *Expected run did not start*
  with the time the run was due, and the pipeline's **Schedule** in the
  **Pipelines** table reads **Running**. The **Services** table lists the
  stage's Dagster when one of its workloads is not ready, with the reason.
- **On the command line:** the scheduler daemon in the stage's Dagster, and its
  pods: `kubectl -n <stage-namespace> get pods -l app.kubernetes.io/name=dagster`.
- **Common causes:** the Dagster daemon is down, scaled to zero or cannot be
  scheduled.
- **Recovery:** bring the daemon back, or start a run. It resolves when a run
  starts. Stopping the schedule closes it without a notification only when the
  product's cadence does not declare that schedule running. If the cadence
  declares it running, stopping it leaves `missed_run` open and also opens a
  `schedule_mismatch`; start a run, or change the declaration first.

### stale_output

Critical, declared as `freshness`. Without thresholds, a running schedule's job
has had no success since the previous due time plus the grace (15 minutes
unless the rule sets `grace`). With `warn_after` or `critical_after`, the last
success is older than that bound, at `warning` or `critical`, whatever the
schedule's state; a job with no success among the last 25 runs opens nothing. A
schedule switched on after its latest due time owes nothing until its next one
plus the grace, so it neither opens nor resolves this incident. It
is not sent while `run_failed` or `missed_run` is open for the same product,
since either already explains it.

- **In the Portal:** **Needs attention** shows *Data is late* or *Data is
  ageing*. In the **Pipelines** table, compare the pipeline's **Last success**
  with its **Latest run**, and open its **Failed runs**, or all its runs in
  **Monitoring → Runs**, to see whether runs are being canceled.
- **On the command line:** `olf pipelines health <stage>` and the job's latest
  runs in `olf runs list`.
- **Common causes:** runs that keep being canceled, a schedule stopped in a
  stage where the rule sets thresholds, or thresholds tighter than the
  product's real cadence.
- **Recovery:** a successful run resolves it. The signal is described in
  [health signals](https://openlakeforge.dev/docs/reference/health-signals/).

### quality

`warning` for a Floe warning or a non-blocking error, `critical` for a blocking
error. It is one incident whose severity can rise, so a warning that becomes a
blocking error sends one `escalated`.

- **In the Portal:** the run's **Quality checks** card lists the checks that did
  not pass, errors first, with the table and column, what the pipeline did
  (quarantined rows, blocked the run, continued) and the counts the engine
  recorded. **Floe report ↗** and **dbt results ↗** under **What failed**
  download the reports. The overview's **Data quality** table gives each
  product's latest checks.
- **On the command line:** the run's checks and reports from the run quality
  route above: which engine, table and check, and the rows it rejected or the
  failures it counted. `olf logs --stage <stage> --run-id <run-id> --component
  floe` shows the Floe validation's own lines.
- **Common causes:** source data that changed shape or content (nulls, values
  that do not cast, duplicate keys), or a Floe contract or dbt test that no
  longer matches the data.
- **Recovery:** fix the data at its source or the contract or test, then rerun.
  It resolves when a later run's complete quality manifest passes. Thresholds
  stay in your Floe and dbt configuration.

### schedule_mismatch

Warning. A PROD schedule that the product's cadence declares running is
stopped in Dagster.

- **In the Portal:** in the PROD stage's **Pipelines** table, the pipeline's
  **Schedule** reads **Stopped**, with the schedule's name.
- **On the command line:** the schedule's state in the stage's Dagster.
- **Common causes:** the schedule was stopped by hand, or the declaration was
  not updated when the product's cadence changed.
- **Recovery:** start the schedule, which resolves the incident with a
  `resolved` notification, or change the declaration so the schedule is no
  longer expected to run, which closes it without a notification.

### sla_breach

Critical, declared as `sla`. The product's declared `sla` was observed breached. The notification names why, as
the cause of the
[observed compliance](https://openlakeforge.dev/docs/reference/health-signals/#product-sla-compliance): `max_age_exceeded`, `run_missed`,
`ready_by_missed`, `quality_below_minimum`, or `upstream:<product>` when a product it reads is the reason, even if the
product's own run succeeded. The condition judges the same evidence as `GET /api/v1/stages/<stage>/sla`.

An `unknown` observation opens nothing and resolves nothing: a stage that was never run, or whose Dagster cannot be
read, is not a breach, and an open incident stays open until the product reads `compliant`. A stopped schedule
suspends the deadline (`not_applicable`) and closes an open incident without a notification.

- **In the Portal:** the product's SLA state is on its context; the incident is in **Monitoring**.
- **On the command line:** the stage's `GET /api/v1/stages/<stage>/sla`, and `olf infra openmetadata drift` if the
  published `sla` looks wrong.
- **Common causes:** a run that failed or did not start (see `run_failed` and `missed_run`), a product it reads that
  is breached, or an objective tighter than the schedule can meet.
- **Recovery:** run the product, or its producer for an `upstream:` cause. It resolves with a `resolved`
  notification when the product reads `compliant`.

### stage_unreadable

Critical, to the platform receivers only. Dagster for a stage could not be
read in 3 consecutive evaluations. While it lasts, that stage's open incidents
are held, not resolved.

- **In the Portal:** the stage's overview reads its pipelines as unknown, with
  the reason, and the **Services** table shows Dagster's workloads and read API
  with their state and reason.
- **On the command line:** the stage's Dagster webserver:
  `kubectl -n <stage-namespace> get pods -l app.kubernetes.io/name=dagster`,
  and the `dagster.read-api` row of `olf health <stage>`.
- **Common causes:** the webserver is down or restarting, or no code location
  is loaded.
- **Recovery:** see [`dagster.read-api`](https://openlakeforge.dev/docs/guides/operations/service-health/#dagsterread-api).
  It resolves on the first evaluation that reads the stage.

### policy_unreadable

Warning, to the platform receivers only. The evaluator could not use a stage's
alert policy. The notification carries a fixed summary, not the cause: the
evaluator logs the cause per stage (see [Check it](#check-it) for the Job's
log).

- **In the Portal:** **Needs attention** lists the incident with its summary
  only; the cause is in the evaluator's log, which needs cluster access.
- **Common causes:** a failed read of the stage's activation or revision, a
  revision file whose digest does not match its sidecar, an `alerts.yml` that
  fails validation (for example a revision built by a newer distribution than
  the evaluator), a revision that has `alerts.yml` without `governance.yml`,
  and a route that names a receiver the profile no longer declares.
- **Meanwhile:** with a last good policy, the evaluator keeps applying it, so
  alerts continue as before. With none (the first evaluation after a deploy, or
  after the cache was lost), the stage is left out of the evaluation: its open
  product incidents are held, not resolved, nothing new opens for it, and a
  queued product notification waits. A policy that cannot be read is not a
  rule that went away.
- **Recovery:** for a stale route, restore the receiver in `openlakeforge.yaml`
  and run `olf infra platform apply`, or change the route in `alerts.yml` and
  deploy a new revision; the other routes keep delivering. For a policy that
  fails validation, run `olf check contracts` on the revision's source and
  deploy a fixed one. The incident resolves, with a notification, on the first
  evaluation that reads the stage's policy cleanly. A stage with no activation,
  or whose revision has no `alerts.yml`, is a normal state and raises nothing.

### service_degraded

Warning or critical, one incident per stage and component, sent to the platform
receivers only. A Dagster or Trino workload that is not ready alerts at
`warning` or `critical`, as `GET /api/v1/stages/{stage}/health/services`
reports it. The object store that cannot be listed and the log archive's spool
age, spool size and newest object alert at `critical` only.

- **In the Portal:** the overview's **Services** table lists the service that is
  not healthy, with each component's state and reason. With metrics on,
  **Monitoring → Metrics** charts each component's CPU and memory.
- **On the command line:** `olf health <stage>`, and the component's `reason`
  there.
- **Common causes and recovery:** per component in
  [service health](https://openlakeforge.dev/docs/guides/operations/service-health/#what-to-do-for-each-component).
- **Resolves** when the component reports `healthy`; an `unknown` or `disabled`
  component changes nothing. There are no reminders.

### health_unreadable

Critical, to the platform receivers only. The platform API's services route
(`GET /api/v1/stages/{stage}/health/services`) could not be read for a stage in
3 consecutive evaluations. While it lasts, open `service_degraded` incidents
stay open: an API that cannot answer is not evidence that the services
recovered.

- **In the Portal:** the Portal reads the same API, so a stage overview that
  cannot read its services points at the platform API rather than a service.
  The checks below need cluster access.
- **On the command line:** the `platform-api` pod:
  `kubectl -n olf-system get pods -l app.kubernetes.io/name=platform-api`.
- **Common causes:** the pod is not ready or restarting, or its settings were
  refused at startup, which its log names.
- **Recovery:** it resolves on the first evaluation that reads the route.

### The runbook link

The local provider sets the runbook page to this guide on GitHub at `main`,
`https://github.com/OpenLakeForge/openlakeforge/blob/main/docs/guides/operations/alerts.md`.
Not the release tag: a build between releases is newer than its version's tag,
and a page or section added since would not be there. To link your own runbook
page, set the platform root's `runbook_base_url` in a variable file and deploy
with it:

```hcl
runbook_base_url = "https://wiki.example.com/data-platform/alerts"
```

```bash
olf infra deploy --var-file runbook.tfvars
```

The URL must be `https` and carry no `#fragment`: the link appends
`#<condition>`, so your page needs a section with each condition's name as its
anchor.

## Check it

Send one test notification to a receiver, of either type, before a real alert
depends on it:

```bash
olf infra alerts test on-call -f openlakeforge.yaml
```

It runs the evaluator once as a Job made from the deployed CronJob, so the
image, credentials, network policy and CA bundle are those of a real alert,
and sends `event: test` to that receiver alone. It prints the receiver's answer
and its log lines, deletes the Job and exits 0 only when the notification was
delivered. `--stage <stage>` picks the stage the notification names, from the
receiver's `stages`. It reads and writes no alert state, so it opens no
incident. Without a deployed receiver it says so and names `olf infra deploy`.

The health routes do not depend on receivers: with none declared,
`GET /api/v1/stages/{stage}/health` still reports a failed run as `critical`.

Failed evaluations stay visible as Jobs, and each run logs one summary line:

```bash
kubectl -n olf-system get jobs -l openlakeforge.io/job=alert-evaluator
JOB=$(kubectl -n olf-system get jobs -l openlakeforge.io/job=alert-evaluator \
  --sort-by=.metadata.creationTimestamp -o name | tail -n 1)
kubectl -n olf-system logs "$JOB"
```

## The limit of an in-cluster evaluator

The evaluator runs inside the cluster it watches. A whole-cluster outage, a
node pool that cannot schedule `olf-system`, a stopped CronJob controller or an
unreachable object store produces no alert. If it cannot read or write its
state it delivers nothing and the Job fails. To catch those cases, watch from
outside: the state object `alerts/state/v1/state.json` carries `evaluated_at`,
the time of the last evaluation, so a monitor that polls it can tell a stopped
evaluator from a quiet one.

---

<small>Synced from openlakeforge @ `v0.7.5-beta.1` (`8a7bf72`), [docs/guides/operations/alerts.md](https://github.com/OpenLakeForge/openlakeforge/blob/8a7bf7296968594c1676b0f581f7c40c3d31b7ba/docs/guides/operations/alerts.md).</small>
