Skip to main content

Overview

An alert rule defines a CEL expression over governance metrics and the channels to notify when that expression evaluates to true. Rules are scoped to a governance entity (virtual key, team, or customer) and can optionally target a specific budget.

Anatomy of a rule

FieldTypeDescription
namestringHuman-readable rule name.
scope_typestringOne of virtual_key, team, customer.
scope_idstringThe ID of the scoped entity. Required.
cel_expressionstringThe CEL expression evaluated against governance metrics. Must evaluate to a boolean.
channel_idsarrayOne or more channel IDs to notify.
target_typestringOptional. Set to "budget" to target a specific budget.
target_idstringThe ID of the target budget. Only valid when target_type is "budget".
descriptionstringOptional description of the rule.
enabledbooleanWhether the rule is active. Default true.
cooldown_millisecondsintegerMinimum milliseconds between notifications for the same rule, scope, and target. Must be a multiple of 1000 (whole seconds). API only; config.json uses cooldown_seconds.

CEL expressions

Rules use CEL expressions evaluated against the CEL variables populated from governance snapshots. Supported operators are ==, !=, >, <, >=, and <=. Expressions can be combined using && (and) and || (or).

Budget examples

Rate limit examples

Compound examples


Scopes

Rules must specify a scope type and a scope ID. The following scopes are supported:
ScopeDescription
virtual_keyA virtual key.
teamA team.
customerA customer.
The scope ID must be non-empty and identify an existing governance entity. The API validates that the referenced entity exists before creating or updating a rule.

Budget targeting

By default, a rule evaluates its CEL expression against every budget belonging to its scope. You can narrow evaluation to a specific budget by setting target_type to "budget" and target_id to the ID of the budget.
Behaviortarget_typetarget_id
Evaluate all budgets in scopeNot set (or null)Not set (or null)
Evaluate a specific budget"budget"The budget’s ID
When a target is set, only metrics for that specific budget are used. The budget usage percentage, absolute spend, and limit reflect that budget alone. Rate limit variables are still populated from the scope’s active rate limits.

Cooldowns

The cooldown prevents alert storms by suppressing repeat notifications after a rule fires. The cooldown window is measured from the latest successful send for the same rule, scope, and target. Live checks use Bifrost’s shared key-value store; alert history is the durable source used to rebuild that state after startup or leadership changes.
  • Default cooldown is 60 seconds. Set to 0 to disable suppression (every match produces a notification).
  • The API accepts cooldown_milliseconds, which must be a whole-second value (multiple of 1000).
  • config.json accepts cooldown_seconds, which is an integer in seconds.
Channels can add their own per-channel cooldown on top of the rule cooldown.

Creating a rule

  1. Open Alerting in the Bifrost dashboard, go to the Rules tab, and click Add Rule.
  2. Enter a Rule Name and optional Description.
  3. Choose a Scope Type and select the Scope entity.
  4. Optionally set a Target Type of budget and select a specific budget.
  5. Build the CEL Expression using the rule builder.
  6. Select one or more Notification Channels.
  7. Optionally set a Cooldown.
  8. Click Create Rule.

Next steps

Alert Channels

Configure the destinations a rule notifies.

Alert History

Review which rules fired and why.