---
title: "Load alert group data | Grafana Cloud documentation"
description: "Load Grafana IRM alert group data into workflows as a resource, with automatic loading for alert group events and explicit declarations for any workflow."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Load alert group data

> Note
> 
> Grafana Workflows is currently in [public preview](/docs/release-life-cycle/). Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

Alert group resources let workflows load full alert group data from Grafana IRM and reference individual fields in step inputs. Workflows loads alert groups when a run starts, before any steps run.

Workflows loads alert groups in two ways:

- **Automatically** for workflows triggered by alert group events
- **Explicitly** through the `resources.alertgroups` section of the workflow definition

## Automatic loading for alert group events

When a workflow triggers on an alert group event (any event matching `grafana_irm_app.alertgroup.*`), Workflows loads the full alert group and makes it available under the key `event`:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
spec:
  name: Respond to alert group
  startWhen:
    matchingRules:
      - eventNameRegex: "grafana_irm_app\\.alertgroup\\..*"
  steps:
    - id: notify
      type: slack.message.post
      inputs:
        channelID: "C0123456789"
        messageText: "Alert group ${resources.alertgroup.event.title} is ${resources.alertgroup.event.state}"
```

You don’t need to configure anything. Workflows reads the alert group ID from the event and loads the current alert group from Grafana IRM.

Automatic loading doesn’t apply when you test a workflow with **Run**. For details, refer to [Test with alert group data](#test-with-alert-group-data).

## Declare alert group resources explicitly

To load alert groups that aren’t part of the triggering event, declare them in the `resources.alertgroups` section. Each entry maps a reference name to an alert group URI using the `alertgroup://id/` scheme:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
spec:
  resources:
    alertgroups:
      related: "alertgroup://id/IXXDXP5KHEGRY"
      current: "alertgroup://id/${inputs.data.alertGroupID}"
```

Each value must use the `alertgroup://id/` prefix followed by the alert group ID. The `id/` segment is required. You can use CEL expressions in the path:

- **Literal URIs**: A constant alert group URI such as `"alertgroup://id/IXXDXP5KHEGRY"`.
- **CEL expressions in the URI**: Use `${expression}` in the path, for example, `"alertgroup://id/${inputs.data.alertGroupID}"` to pull the ID from the triggering event data.

## Reference alert group fields in step inputs

To use an alert group field in a step input, write `${resources.alertgroup.<KEY>.<FIELD>}`:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
steps:
  - id: post-summary
    type: slack.message.post
    inputs:
      channelID: "C0123456789"
      messageText: |
        Alert Group: ${resources.alertgroup.event.title}
        State: ${resources.alertgroup.event.state}
        Alerts: ${resources.alertgroup.event.alerts_count}
```

### Available fields

The alert group object contains the fields that the Grafana IRM alert groups API returns. Common fields include:

Expand table

| Field             | Type   | Description                                         |
|-------------------|--------|-----------------------------------------------------|
| `id`              | string | The alert group identifier.                         |
| `title`           | string | The alert group title.                              |
| `state`           | string | Current state, for example, `firing` or `resolved`. |
| `alerts_count`    | int    | Number of alerts in the group.                      |
| `created_at`      | string | When the alert group was created (RFC 3339).        |
| `resolved_at`     | string | When the alert group was resolved (RFC 3339).       |
| `acknowledged_at` | string | When the alert group was acknowledged (RFC 3339).   |
| `silenced_at`     | string | When the alert group was silenced (RFC 3339).       |

The exact fields available depend on the API response. For the complete schema, refer to the [Grafana IRM alert groups API](/docs/grafana-cloud/alerting-and-irm/irm/reference/oncall-api/alertgroups/).

## Combine automatic and explicit resources

A workflow can use both automatic and explicit alert group resources. When a workflow triggers on an alert group event and also declares explicit resources, both are available. If an explicit entry uses the key `event`, it overrides the auto-loaded alert group:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
spec:
  startWhen:
    matchingRules:
      - eventNameRegex: "grafana_irm_app\\.alertgroup\\.updated"
  resources:
    alertgroups:
      related: "alertgroup://id/IXXDXP5KHEGRY"
  steps:
    - id: compare
      type: transform
      inputs:
        template: "Event alert group: ${resources.alertgroup.event.title}, Related: ${resources.alertgroup.related.title}"
```

In this example, `resources.alertgroup.event` is auto-loaded from the triggering alert group event, and `resources.alertgroup.related` is loaded from the explicitly declared ID.

## Test with alert group data

When a Grafana IRM event triggers a workflow, Workflows loads the alert group automatically. When you test with **Run**, it doesn’t, and trigger filters don’t apply. To test a workflow that uses alert group data, add the resource yourself:

1. Open the **More** menu, select **Settings**, and select the **Resources** tab.
2. Click **Add Resource**.
3. Set **Type** to **Alert Group**, **Name** to `event`, and **URI** to `alertgroup://id/${inputs.data.alertGroupID}`.
4. Click **Save**.

Make sure the event data uses the ID of a real alert group in your stack.

You can keep the resource after you finish testing. When a real event triggers the workflow, it loads the same alert group.

## Error handling

If Workflows can’t load an alert group, for example, because the ID doesn’t exist, the run fails before any steps run. This applies to both auto-loaded and explicitly declared alert groups.

## Next steps

- [Create workflows](/docs/grafana-cloud/platform/workflows/create-workflows)
- [Load incident data](/docs/grafana-cloud/platform/workflows/load-incident-data)
- [Use CEL expressions](/docs/grafana-cloud/platform/workflows/use-expressions)
- [Manage secrets](/docs/grafana-cloud/platform/workflows/manage-secrets)
- [Step types reference](/docs/grafana-cloud/platform/workflows/reference)
