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

# xMatters

> Optional — connect xMatters so alerts can escalate out of chat (one HTTP trigger, API-key auth). Written from the live-proven setup on 0.5.132.

ⓘINFO

**Setup wizard → the Paging step.** Sariva pages through exactly **one** provider per install — `none`, PagerDuty or xMatters — chosen in the wizard. This page is the xMatters side, step by step as it was proven live on the Sariva VM (0.5.132, 2026-10-16): a real consumer-lag alert paged xMatters and auto-terminated when the lag recovered.

Sariva posts every page to **one xMatters Flow Designer HTTP trigger**, authenticated with an xMatters **API key + secret** (HTTP Basic). The same trigger carries both actions: `action: "trigger"` when an alert fires and `action: "resolve"` when the condition clears, correlated by `sariva_key` — the key Sariva mints per episode: `<app alias>-<alert type>` for an app alert, `<cluster alias>-<pod>-oom_killed` for a CFK pod OOMKilled page. Your flow creates the alert and, on resolve, finds it by `sariva_key` and terminates it. No REST user, no role, and Sariva never stores an xMatters alert id.

## What you need first

* [ ] An xMatters account. The **Free** plan is enough and accepts a personal email: it includes API access, Flow Designer and webhooks (email and mobile push only — no SMS/voice). Your instance URL is `https://<company>.xmatters.com`.
* [ ] A user who will own the integration — its API key is what Sariva authenticates with.

## Step 1 — Create the workflow

**Workflows → Workflows → Create** → **Custom Workflow** (an **Empty Workflow**). Name it `Sariva`.

## Step 2 — Properties FIRST, with maximum lengths

Open the workflow's **PROPERTIES** tab and create five **Text** properties. **Set the Maximum Length on each** — the default is **30 characters**, which silently truncates `sariva_key` (`payments-consumer-lag_threshold` is 31) so the resolve then matches nothing and alerts never close. This was the root cause in the live test.

| Property | Type | Maximum length | Carries |
| - | - | - | - |
| `sariva_key` | Text | **200** | The correlation key — what the resolve looks up |
| `summary` | Text | **500** | The alert title |
| `severity` | Text | **50** | `critical` / `error` / `warning` / `info` |
| `cluster` | Text | **200** | The cluster alias |
| `runbook_url` | Text | **1000** | Your runbook link — the app registration's `runbook_url`, or empty when the app has none (see the payload contract below) |

## Step 3 — The form

**FORMS → Create Form**, name `Sariva alert`.

1. **Layout**: add the five properties.
2. **Recipients**: add the users or groups to notify — an alert with no recipients is created but notifies nobody.
3. **MESSAGES**: set the **subject** to the `summary` property and a **body** that shows `severity`, `cluster`, `sariva_key` and `runbook_url`. Without this the notification arrives as **"(No Subject)"**.
4. **DEPLOY the form** — it starts as "Not Deployed" and an undeployed form cannot be used by the flow.

## Step 4 — The flow canvas

**FLOW DESIGNER → Create Flow Canvas**, name `Sariva paging`. **Save after every step** — the canvas session times out and loses unsaved steps.

### The trigger (custom, not the built-in webhook)

The built-in **"Initiate by HTTP (Webhook)"** trigger does **not** work for Sariva: its outputs are fixed (Summary / Message / Recipients) and its authentication is locked. Instead, at the bottom of the **Triggers** palette, click **+ Create HTTP Trigger**:

* **Authentication Method**: **API Key**.
* **Outputs**: `action`, `sariva_key`, `summary`, `severity`, `cluster`, `runbook_url`.
* **Script**:

  ```javascript theme={null}
  var payload = JSON.parse(request.body);
  output['action']      = payload.action || '';
  output['sariva_key']  = payload.sariva_key || '';
  output['summary']     = payload.summary || '';
  output['severity']    = payload.severity || '';
  output['cluster']     = payload.cluster || '';
  output['runbook_url'] = payload.runbook_url || '';
  ```

The trigger's **Settings** show its URL — that is `XMATTERS_TRIGGER_URL`.

### The steps

```
HTTP Trigger ──► Switch (Property = <trigger>.action; paths "trigger" and "resolve")
                   ├─ "trigger" ──► Create Alert Using a Form
                   │                 (form: Sariva alert; map the five properties
                   │                  from the trigger outputs; recipients from the form)
                   └─ "resolve" ──► Get Alerts ──► Terminate Alerts
                                    Status: ACTIVE          Alert IDs: <Get Alerts>.Alert IDs
                                    Property Name: sariva_key#en
                                    Property Value: <trigger>.sariva_key
                                    Exact Property Value Match: TRUE
```

⚠WARNING

**`sariva_key#en` — the `#en` locale suffix is REQUIRED.** Get Alerts filters Text properties by `<name>#<locale>`; with plain `sariva_key` it returns 0 alerts and nothing ever terminates. Confirmed live.

### Re-fire dedup on the trigger path — proven on 2026-10-16

ⓘRECOMMENDED TRIGGER-PATH SHAPE

Sariva re-fires an alert only when it gets materially worse (severity escalation or the magnitude at least doubling — [Alerting](https://sariva.mintlify.site/concepts/alerting.md)). Each re-fire is a new `trigger` call on the same `sariva_key`, and the flow above creates a **new xMatters alert each time** — the live run produced four alerts for one incident. To collapse them, change the `trigger` path to: **Get Alerts** (Status ACTIVE, Property Name `sariva_key#en`, Property Value `<trigger>.sariva_key`, Exact match TRUE) → **Switch** on its **"Number of Alert IDs Returned"** output → path **`0`** → **Create Alert Using a Form**; any other count → nothing (the existing alert stays). **Proven on 2026-10-16:** two triggers with the same `sariva_key` (both `202`) produced one alert, and the resolve (`202`) closed it. This is the recommended shape for the `trigger` path; the choice is yours — the flow is your workflow, not Sariva code.

## Step 5 — The API key

Your profile → **More Actions → API Keys → Create API Key Credential**.

| Sariva variable | Value |
| - | - |
| `XMATTERS_API_KEY` | The **User API Key** (`x-api-key-…`) — the Basic-auth username |
| `XMATTERS_API_SECRET` | The credential's **secret** — shown **once**; the Basic-auth password |
| `XMATTERS_TRIGGER_URL` | The custom trigger's URL from its **Settings** (`https://<company>.xmatters.com/api/integration/1/functions/<id>/triggers`) |

## Step 6 — Test with curl before configuring Sariva

Trigger, then resolve, from any machine:

```bash theme={null}
curl -sS -u "x-api-key-…:<secret>" -H 'Content-Type: application/json' \
  -X POST "https://<company>.xmatters.com/api/integration/1/functions/<id>/triggers" \
  -d '{"action":"trigger","sariva_key":"curl-test-1","summary":"Sariva curl test","severity":"info","cluster":"test","runbook_url":""}'
# → {"requestId":"…"}  and a new ACTIVE alert in xMatters

curl -sS -u "x-api-key-…:<secret>" -H 'Content-Type: application/json' \
  -X POST "https://<company>.xmatters.com/api/integration/1/functions/<id>/triggers" \
  -d '{"action":"resolve","sariva_key":"curl-test-1"}'
# → {"requestId":"…"}  and the alert shows Terminated
```

If the second call leaves the alert ACTIVE, go back to Step 2 (maximum lengths) and the `#en` suffix in Step 4.

## Step 7 — Configure Sariva and validate

| Wizard asks | You give |
| - | - |
| Which paging provider? | `xMatters` |
| `XMATTERS_TRIGGER_URL` | The trigger URL from Step 5 |

The two secrets are not asked; the wizard names where they go: `.env` on the VM path (`XMATTERS_API_KEY=` / `XMATTERS_API_SECRET=` replace their `REPLACE_ME_*` placeholders; `PAGING_PROVIDER=xmatters` and `XMATTERS_TRIGGER_URL=` are written for you), `setup-secret.sh` on the Kubernetes paths (with `values.yaml` carrying `paging.provider: xmatters` and `paging.xmatters.triggerUrl`). Hand-authored `values.yaml` shape:

```yaml theme={null}
paging:
  provider: xmatters
  xmatters:
    existingSecret: sariva-platform-extras
    triggerUrl: https://<company>.xmatters.com/api/integration/1/functions/<id>/triggers
    apiKeySecretKey: XMATTERS_API_KEY
    apiSecretSecretKey: XMATTERS_API_SECRET
```

Then:

```bash theme={null}
sariva validate paging
#   → xMatters: sending a test alert to <company>.xmatters.com …
#   ✓ Paging                 test alert sariva-validate-20261016T093012Z: trigger and resolve both
#                            accepted by xMatters (requestId … / …) — confirm in xMatters that the
#                            test alert shows Terminated
```

The validate alert is created and terminated **within a second**, so it may never reach an inbox or appear in the alerts list. Confirm in the flow's **Activity** panel instead: one run for the trigger, one for the resolve, and **Get Alerts → "Number of Alert IDs Returned" = 1** on the resolve run. `sariva validate all` checks the configuration only and never sends an alert.

## Payload contract and customisation

Every page Sariva sends is one POST to your trigger with this JSON body:

| Field | Value |
| - | - |
| `action` | `"trigger"` when an alert fires or re-fires; `"resolve"` when the condition clears |
| `sariva_key` | `<app alias>-<alert type>` for an app alert; `<cluster alias>-<pod>-oom_killed` for a CFK pod OOMKilled page — the correlation key, identical on trigger and resolve |
| `summary` | The alert title (same text as the chat alert) |
| `severity` | `critical` / `error` / `warning` / `info` |
| `priority` | `HIGH` / `MEDIUM` / `LOW`, derived from severity |
| `cluster` | The cluster alias |
| `app`, `team`, `consumer_group` | From the app registration |
| `runbook_url` | **Your** runbook URL for the app — the registration's `runbook_url` field ([Register an app](https://sariva.mintlify.site/app-teams/register.md)) — or `""` when the app has none. Sariva never sends its internal knowledge-base paths to a page. |
| `source` | `"sariva-platform"` |
| `details` | The full alert context the chat alert carries: `app_alias`, `team`, `slack_channel`, `cluster_alias`, `cluster_id`, `bootstrap_servers`, `consumer_group_id`, `topics_subscribed`, `alert_type`, plus the type-specific numbers (`current_lag`, `lag_threshold`, `restart_count`, `patterns_matched`, `log_group`, …) |

A `resolve` carries only `action`, `sariva_key` and `source`.

**OOMKilled pages** (the cluster-infra engine) use the key `<cluster alias>-<pod>-oom_killed`, send `runbook_url` as `""`, and carry no app, team or consumer group (`app`, `team` and `consumer_group` are `null`). Their `details` name the cluster, component, pod, namespace, container, restart count, exit code and kill time (`cluster_alias`, `component`, `pod`, `namespace`, `container`, `restart_count`, `exit_code`, `finished_at`, `alert_type`, `lifecycle`).

**The xMatters workflow is yours.** Property names, recipients, routing, escalation and message text are your decisions; the trigger script is the mapping layer between Sariva's payload and your form (map `details.*` onto more properties if you want them). Two hard rules keep it working:

1. **Use `action` to tell a fire from a resolve.** Both arrive on the same trigger.
2. **Keep `sariva_key` on the alert** (a property, with a maximum length ≥ 200) and look it up with `sariva_key#en` on the resolve path — or alerts will not auto-close.

Anything Sariva does not send today is a Sariva change, not a workflow change — ask for it rather than deriving it in the flow.

## Limits

* **Every Sariva page auto-terminates.** Per-app alerts (lag, error pattern, pod restarts, rebalances) resolve when the condition clears; the cluster-infra **OOMKilled** page (CFK pods on EKS) resolves once the pod has been Running and Ready with no new kill for 15 consecutive reads. A pod that is gone (scale-down) counts as a clean read, so it closes after 15 reads, not instantly. A further kill while the page is open updates the chat and never opens a second page. A failed pods read is not a clean read, so a page never closes on missing data. (A pod's memory percentage is never alerted on — Kafka pods sit at 90-95% because Linux uses free memory as page cache.)
* **Free plan** — email and mobile push only; no SMS or voice.
* **Rate limit** — xMatters limits requests per minute per plan and answers `429` without queueing.
* **A resolve that is not accepted is retried.** Any resolve xMatters does not accept — throttled, rejected or unreachable — is retried on later checks, up to 10 attempts in total, then dropped with a `paging_resolve_abandoned` log line. A resolve is only sent to the provider that accepted the trigger.
* **A trigger that fails is not retried** — including a `429`. The chat alert still posts, but that episode has no xMatters alert, so there is nothing to resolve when it clears. The failure is logged as `paging_trigger_failed`.

## Troubleshooting (from the live run)

* **`404 Unable to find Integration`** on validate or curl → the trigger URL is wrong or still a placeholder. Copy it again from the custom trigger's **Settings**.
* **Alert never closes** → `sariva_key` was truncated (property maximum length still 30 — Step 2) or Get Alerts uses `sariva_key` without `#en` (Step 4). Check the resolve run's Get Alerts output: "Number of Alert IDs Returned" must be 1.
* **Notification arrives as "(No Subject)"** → the form's MESSAGES subject/body are not set (Step 3).
* **`accepted` but no alert appears** → open the flow's **Activity** panel and look for the failing step (an undeployed form, an unmapped property, no recipients).
* **`credentials rejected` (401/403)** → wrong key/secret pair, or the trigger's Authentication Method is not **API Key**.
* **`rate-limited` (429)** → the per-minute limit; wait a minute and retry.
* **`unreachable`** → allow `<company>.xmatters.com` on port 443 from the install.
* **Four alerts for one incident** → re-fires on the same key; add the dedup branch above (proven on 2026-10-16).

## Return to the deployment path

> [card] [Back to the AWS EKS path](https://sariva.mintlify.site/deploy/aws-eks-cc.md)
>
> Paging is optional. After you have the trigger URL and the API key, return to your deployment path and continue with the next card.

> [card] [Back to the VM path](https://sariva.mintlify.site/deploy/vm-docker-cc.md)
>
> Running on a Linux VM? Put the key and secret in `.env` and continue the VM checklist.


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