Set Up Alert Rules
Start with a template to obtain a supported configuration. A template supplies defaults and records its ID and version; it does not keep saved rules synchronized with later catalog changes.
You can set up a rule in the Admin Console or through the Alerts API.
- Create an alert from a chart when you already have the agent or AI Gateway metric open.
- Monitor Native Object values and activity with a state or audit-history rule.
- Use a template with the Alerts API to automate rule setup.
Create a Threshold Rule from a Template
In the Admin Console
In the Admin Console, open Operate → Alerts → Templates, choose a threshold template, set its parameters and destination, and select Review configuration. Before selecting Enable alert, review the condition, resources it monitors, notification destination, and recovery preference. The Admin Console saves the rule and then creates its subscription.
Notify on recovery is checked by default. For Native Object and attachment templates, use the API template catalog.
To receive notifications when a stop, restart, or deletion is requested for an Agent or Worker, set up a lifecycle subscription. By default, the subscription covers all current and future Agents and Workers. Choose Specific deployments to limit the subscription to the deployments you select.
With the API
Confirm the target tenant and use its Alerts API base URL and credentials. For direct requests, send the tenant’s organization ID in x-org-id. Have a destination ID ready. Use a test destination to verify delivery with test traffic.
You need contextual:alert-rules:read, contextual:alert-rules:create, contextual:alert-subscriptions:create, and read access to the metric source. Check the source permissions for AI metrics if you’re configuring an AI Gateway rule. Before enabling a metrics rule, confirm background metrics access is ready. You can save a disabled draft before enrollment.
- List templates with
GET /templates. Render a template withPOST /templates/{id}/render, passing the inputs inparameters. Record the returned template ID and version. - Check the returned
kind. For a subscription, set up a lifecycle subscription. For a rule, sendconfigtoPOST /rules/validate. Confirmvalidand everyguardRails[].okare true before saving. Review the condition and scope. If supported, sendconfigtoPOST /rules/previewand review its coverage. - Review the destination and recovery preference. A rule can fire before its subscription exists. If receiving the first firing notification matters, set
enabledtofalseinconfig. Sendconfigas the body ofPOST /rulesand omitid. - Use the saved rule’s
_metaData.idto create its destination subscription. If you saved the rule disabled, enable it using its current hash. This requirescontextual:alert-rules:update. - Check that the rule evaluates. Use controlled test traffic to confirm firing in alert history and receipt at the destination. Verify recovery where supported. To check history and delivery details through the API, you need
contextual:alert-instances:read. Disable or delete the test rule and remove unused test routes and destinations when done.
Example Template Parameters
- Repeated agent startup failures. Send
{ "parameters": { "agentScope": "selected", "agentIds": ["TEST_AGENT_ID"], "threshold": 3, "window": "15m" } }toPOST /templates/agent-termination-threshold/render. This detects more than three starting-to-terminated transitions in 15 minutes for each selected agent. Without selected-agent coverage, the rule covers current and future reported agents. Historical preview is unavailable for this metric. Verify the rule with live test data. - AI Gateway attempt failure rate above 5%. Send
{ "parameters": { "threshold": 0.05, "window": "5m" } }toPOST /templates/ai-error-rate-high/render. The threshold is a ratio. See the full rule body for the metric and evaluation settings.
Edit a Rule
The Admin Console supports creating and editing alerts from supported charts. The Rules list provides Enable, Disable, Delete, and Edit notifications actions; use the chart editor for a matching condition or the API for other rule configurations.
For an API update, read the current rule, edit and validate its complete writable configuration, then submit it with the current hash. See safe writes for the request and how to handle conflicts.
Changing the metric, grouping, target, query, window, or threshold can change which series are tracked and restart active evaluation. Review existing subscriptions and silences after such changes. See How alerts fire and notifications are delivered.
Disable or Delete
The Admin Console's Rules actions include Disable, Enable, and Delete. Disabling stops evaluation while retaining configuration. Re-enabling a metrics rule checks current authoring requirements, including enrollment.
Deleting a rule also deletes its rule-bound subscriptions. Label-policy subscriptions remain because they can cover other rules. Do not delete a rule merely to mute notifications during maintenance; use a silence.
For multiple resources, use declarative apply. Inspect the plan first and check the per-item results afterward for partial changes.