# Create and Test Your First Backlog Alert

These instructions apply to the current Admin Console.

{% hint style="info" %}
Alerts are in early access and may not be available in your account. [Contact Contextual support](mailto:help@contextual.io) to request that Alerts be enabled for your tenant.
{% endhint %}

Create a backlog alert for a test event Worker in the Admin Console. Watch it fire, then let the Worker drain its backlog and verify that the alert resolves. This exercise changes alert configuration and sends notifications to the destination you select.

## Before You Start

Use a dev tenant with Alerts and Workers enabled, and a dedicated test event Worker deployed with the `managed-event-worker` template. You need to be able to send test events to the Worker’s topic and slow processing while the Worker stays healthy. See [Events and Schedules](https://docs.contextual.io/build/contextual-workers/connect-to-contextual.md#events-and-schedules) for event Worker setup. A tenant administrator must enable [background metrics access](https://docs.contextual.io/operate/alerts/background-metrics-access.md).

The backlog template requires the following permissions.

* `contextual:alert-rules:read` to open **Templates** and review the rule.
* `native-object:agent:read` to select the test Worker and access its backlog metric.
* `contextual:alert-rules:create` and `contextual:alert-subscriptions:create` to save the rule and its notification route.
* `contextual:alert-destinations:read` to choose a destination.

Prepare a Slack incoming webhook for a test channel or a publicly reachable HTTPS test receiver. A generic receiver must implement [signature verification and deduplication](https://docs.contextual.io/operate/alerts/webhook-receivers.md). Localhost and private-network URLs are not valid delivery targets. Choose a destination whose recipients expect test notifications.

## 1. Create a Destination

1. Open **Operate → Alerts → Destinations**.
2. Select **Create destination** (requires `contextual:alert-destinations:create`).
3. Enter a **Label**, choose **Slack webhook** or **Generic webhook** under **Kind**, and enter the **Webhook URL**.
4. Select **Save**. For a generic webhook, select **Reveal signing key** (requires `contextual:alert-destinations:update`) and configure that key in your receiver's secret storage.
5. Select **Done**. The destination should appear in the list.

## 2. Enable the Metrics Connection

If the page shows **Set up metrics alerting**, have an administrator with the [metrics enrollment permissions](https://docs.contextual.io/tenants/tenant-apis/alerts-api/metrics-enrollment.md) open it and select **Enable metrics alerting**. Wait until the connection is ready. Connection health notifications are optional and independent of notifications for the backlog rule.

If a connection is already ready, use it. Do not reconnect working credentials just to run this exercise.

## 3. Review and Enable the Template

1. Open **Templates** and select **Set up Backlog remains above a threshold**.
2. The default is **All current and future topics reporting subscription backlog**. For this test, choose **Specific deployments**. Under **Selected deployments**, select only your test Worker.
3. Set **Backlog threshold** to `1` message and **Must remain above for** to `1m`.
4. Choose the test **Destination** and leave **Notify on recovery** checked.
5. Select **Review configuration**. Inspect the selected Worker, threshold, duration, and generated configuration. Validation must pass. Historical preview is unavailable for this platform metric; that message does not mean the live rule is unsupported.
6. Select **Enable alert**, then **Done** after successful setup.

The Admin Console creates the rule and then its destination subscription. If it reports that the rule is saved but routing is incomplete, use **Retry notification route**. If the save outcome is uncertain, inspect **Rules** and **Destinations → Advanced routing** before retrying the whole setup. Viewing subscriptions in **Advanced routing** requires `contextual:alert-subscriptions:read`.

## 4. Observe Firing and Delivery

Slow processing on the test Worker. For example, configure the test handler to wait a few seconds before returning successfully for each event. Send a batch of test events to the Worker’s topic faster than it can process them. Keep the Worker healthy and reporting metrics, with at least two messages queued, until the alert fires.

Open **Rules** to inspect evaluation status, then **Alerts** to inspect the resulting instance. Viewing alert history and delivery details requires `contextual:alert-instances:read`. Allow time for metrics ingestion, evaluation, and at least one minute of observed breach. The threshold is strictly greater than one, so a backlog of exactly one does not breach.

Expect a pending condition before firing. Once firing, open the alert details and inspect the delivery outcome. Confirm the corresponding message in the test channel or receiver. A firing row alone does not prove delivery. If nothing arrives, check [routing and delivery](https://docs.contextual.io/operate/alerts/troubleshooting.md) before changing the threshold.

## 5. Observe Recovery

Restore the Worker’s normal processing speed and let it finish processing the test events. Keep metrics reporting until a successful observation is at or below the threshold. The alert should resolve; the template-created subscription receives recovery notifications by default.

If the Worker’s metrics disappear, check the alert for a possible stale state.

## 6. Clean Up

In **Rules**, disable the test rule with `contextual:alert-rules:update` and the same access to the backlog metric used during setup. When you no longer need the rule, delete it with `contextual:alert-rules:delete`. Deleting the rule also removes its rule-bound subscriptions. Organization label-policy subscriptions remain.

If other subscriptions still use the test destination, remove them with `contextual:alert-subscriptions:delete` or repoint them with `contextual:alert-subscriptions:update`. Deleting the destination requires `contextual:alert-destinations:delete`. Keep a healthy tenant metrics connection if other rules depend on it.

To monitor other signals, [set up alert rules](https://docs.contextual.io/operate/alerts/manage-rules.md) in the Admin Console or through the Alerts API.
