Alerts and notification delivery
Alerts turn the latest result of a query into a small state machine. When the state changes, Redash can send a message to each subscriber through an email address or an organization-managed notification destination.
Alert lifecycle
An alert belongs to one query and evaluates one result column against a threshold. Query execution supplies the latest result, while the alert task decides whether the result represents a new event.
Alert evaluation
The evaluation reads the latest query result and selects either the first value or the minimum or maximum value from the configured column. It compares that value with the configured threshold by using an operator such as >, <=, ==, or !=.
The result becomes one of three operational states:
| State | Meaning |
|---|---|
triggered | The selected value meets the alert condition. |
ok | The selected value does not meet the condition. |
unknown | Redash cannot make a valid comparison, such as when the result is missing or the values cannot be converted for the comparison. |
References: redash/…/__init__.py• L935-978 redash/…/__init__.py• L1015-1049
State-change notification
After a query result is stored, the query execution flow queues alert evaluation. The alert task saves the new state before it sends notifications. It normally sends only when the state changes, or when a triggered alert passes its optional rearm period. A transition from unknown to ok does not send a message because it does not represent a confirmed recovery.
Muted alerts still record their new state but do not send their subscriptions. The query execution path is part of the wider background work system described in Background jobs and scheduling.
This diagram shows how a query result becomes an alert event and then reaches its subscribers.
flowchart LR
A[Query execution] --> B[Latest query result]
B --> C[Alert evaluation]
C --> D{State change or rearm}
D -->|No| E[Save no notification]
D -->|Yes| F[Save alert state]
F --> G{Muted or unknown to ok}
G -->|Yes| H[Stop]
G -->|No| I[Notify subscriptions]
I --> J[Email or configured destination]
References: redash/…/execution.py• L243-259 redash/…/alerts.py• L11-54
Alert APIs
The alert API lets users with access to the source query view and manage alerts. It also separates alert ownership from subscription ownership so that a user can receive an alert without owning its definition.
Alert management API
The main alert resource supports listing alerts visible through the current user's data-source groups, creating an alert for an accessible query, updating its name, source query, and condition settings, and deleting it. Alert owners and administrators can change or delete an alert. The API also exposes its current state and its link to the source query.
| Operation | Path | Purpose |
|---|---|---|
| List or create | /api/alerts | Find visible alerts or create one for a query. |
| Read, update, or delete | /api/alerts/<alert_id> | Manage one alert. |
| Evaluate | /api/alerts/<alert_id>/eval | Evaluate an alert on demand. |
| Mute or unmute | /api/alerts/<alert_id>/mute | Stop or resume automatic delivery. |
References: redash/…/alerts.py• L23-121 redash/…/api.py• L119-132
Subscription API
An alert subscription joins a user to an alert and can optionally name a saved notification destination. A subscription without a destination uses the subscribing user's email address. Users need access to the alert to subscribe or list subscriptions, while the subscriber or an administrator can remove a subscription.
| Operation | Path | Purpose |
|---|---|---|
| List or create | /api/alerts/<alert_id>/subscriptions | View subscribers or add the current user. |
| Delete | /api/alerts/<alert_id>/subscriptions/<subscriber_id> | Remove one subscription. |
References: redash/…/alerts.py• L123-166 redash/…/__init__.py• L1443-1486
Manual evaluation API
The evaluate endpoint gives an alert owner or administrator a direct check without waiting for the next query run. It updates the stored state only when the normal notification rule says that a state event exists. Its dispatch call is separate from that check, so a manual evaluation can call subscribers even when automatic evaluation would suppress delivery.
References: redash/…/alerts.py• L57-70 redash/…/alerts.py• L20-26
Destination configuration
A notification destination is a named, organization-scoped delivery target. Administrators create it from a registered destination type, and the type supplies the fields needed to validate and use its settings.
Destination catalog
The destination catalog is loaded at application start and can be narrowed or extended through destination settings. The supported catalog covers the following delivery roles:
| Role | Supported examples | Typical result |
|---|---|---|
| Sends an HTML alert message to one or more addresses. | ||
| Messaging | Slack, Discord, Mattermost, ChatWork, Google Hangouts Chat, Microsoft Teams Webhook, Webex | Posts the alert state and useful links to a room, channel, or person. |
| Incident management | PagerDuty | Opens or resolves an incident for the alert. |
| Webhook | Generic Webhook | Sends a JSON state-change event to an HTTP endpoint. |
| Event and task systems | Datadog, Asana | Records the alert as an external event or task. |
An unavailable optional dependency can remove a destination type from the catalog. For example, PagerDuty is registered only when its client library is available.
References: redash/…/__init__.py• L370-389 redash/…/__init__.py• L8-79 redash/…/pagerduty.py• L5-19
Destination administration
Administrators can list available types, create or edit organization destinations, and delete them through /api/destinations. Creation and updates validate the settings against the selected type. Secret settings are stored in protected configuration data and are masked when returned to the client.
An alert subscription stores only the selected destination relationship. This lets one saved destination serve many alerts and keeps destination changes separate from alert conditions.
References: redash/…/destinations.py• L15-134 redash/…/__init__.py• L1389-1440 redash/…/api.py• L280-282
Delivery content
Every destination receives the alert, its source query, the subscriber, the new state, the organization base URL, and evaluation metadata. Each integration then maps that shared event to its own external message or API request.
Alert message context
Alert messages can use a custom subject and body. The body can include the alert name and state, query and alert links, the selected result, the condition, and the query result table. If no custom body exists, email uses the standard alert template and integrations use their own concise default message.
References: redash/…/__init__.py• L1051-1089 redash/…/alert.html• L53-86
Integration delivery
Messaging destinations present a human-readable state change with links back to Redash. Mattermost posts the custom subject or a default triggered or recovered message and can add a custom body as an attachment. PagerDuty maps triggered to an incident trigger and ok to a resolve action. The generic webhook preserves the alert and metadata in a JSON event so another system can apply its own routing.
External delivery is best understood as a set of adapters with a shared input rather than as one common message format:
- Email sends the rendered HTML body to comma-separated addresses.
- Messaging adapters send provider-specific cards, attachments, or text.
- Mattermost accepts a protected webhook URL plus optional username, icon, and channel settings.
- PagerDuty uses a stable alert-and-query key so a recovery can resolve the matching incident.
- The generic webhook sends
event, serialized alert data, the Redash base URL, and evaluation metadata.
References: redash/…/email.py• L9-57 redash/…/slack.py• L24-61 redash/…/mattermost.py• L9-60 redash/…/pagerduty.py• L43-79 redash/…/webhook.py• L29-56
Change checklist
When these files or sections are changed, remember to consider these:
- Keep alert state names and transition rules aligned between redash/…/__init__.py and every destination that maps state to external status.
- Keep the subscription fallback to user email aligned with the destination configuration schema. A missing destination is a deliberate email path.
- Keep destination type registration, the administrator API, and the client-facing configuration schema aligned when adding or disabling an integration.
- Preserve the alert and query links and webhook metadata contract when changing serialized alert fields or alert message context.
- Review the interaction between query-result storage and queued alert checks when changing query execution or background job behavior.
- Keep alert ownership checks and source-query access checks aligned across alert creation, updates, manual evaluation, and subscription management.
- Keep Mattermost's protected webhook setting and optional message fields aligned between its destination schema and its outbound payload.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The latest result is absent, empty, missing the selected column, or cannot be compared with the threshold. | The alert becomes unknown, so it does not represent a confirmed breach or recovery. | Return a usable result with the configured column and a threshold of the matching type. |
| An alert is muted. | Automatic state changes are saved without delivery. | Unmute the alert before expecting subscriber messages. |
| A destination type is not registered because its dependency is unavailable. | Administrators cannot select or create that destination type. | Install the required dependency or use a registered destination. |
| An external provider rejects a request or times out. | That subscription's delivery fails and the error is logged. | Check provider credentials, endpoint settings, and provider response logs. |
| A Mattermost webhook URL is invalid or returns a non-success response. | Mattermost does not receive the alert, and the send error is logged. | Use a valid webhook URL and check the Mattermost response. |
| A manual evaluation is used as a delivery test. | Subscribers can be called even when the normal automatic rule would suppress the event. | Treat manual evaluation as an explicit dispatch path, not as a silent read-only check. |
| A caller lacks access to the alert or its source query. | The API rejects the operation instead of exposing or changing alert data. | Grant the needed alert and query access before using the alert API. |
Key files
| File | Why to read it |
|---|---|
| redash/…/__init__.py | Defines alert states, evaluation inputs, subscriptions, and destination relationships. |
| redash/…/alerts.py | Shows the automatic state-change and notification flow. |
| redash/…/execution.py | Shows when a fresh query result queues alert checks. |
| redash/…/alerts.py | Defines alert, mute, manual evaluation, and subscription API behavior. |
| redash/…/destinations.py | Defines organization-level destination administration and validation. |
| redash/…/__init__.py | Defines the shared destination contract and type registration. |
| redash/…/__init__.py | Lists the default destination integrations and their enablement settings. |
| redash/…/webhook.py | Illustrates the generic JSON webhook event contract. |
| redash/…/mattermost.py | Illustrates Mattermost webhook delivery and its message options. |
| redash/…/pagerduty.py | Illustrates incident trigger and recovery behavior. |
| redash/…/email.py | Illustrates rendered email delivery and alert templates. |