---
layout: "fastly"
page_title: "Fastly: alert"
sidebar_current: "docs-fastly-resource-alert"
description: |-
  Provides a Fastly Alert. Alerts send notifications to custom integrations (e.g., Slack channels, PagerDuty, Microsoft Teams and New Relic) when an observed metric either exceeds or falls below a threshold.
---

# fastly_alert

Provides a Fastly Alert. Alerts send notifications to custom integrations (e.g., Slack channels, PagerDuty, Microsoft Teams and New Relic) when an observed metric either exceeds or falls below a threshold.

## Example Usage

```terraform
resource "fastly_service_vcl" "example" {
  name = "my_vcl_service"
  domain {
    name    = "demo.notexample.com"
    comment = "demo"
  }
}

resource "fastly_integration" "example" {
  name = "my_integration"
  type = "a_valid_type"

  config = {
    webhook = "some_webhook"
  }
}

resource "fastly_alert" "example" {
  name       = "my_vcl_service errors"
  service_id = fastly_service_vcl.example.id
  source     = "stats"
  metric     = "status_5xx"

  evaluation_strategy {
    type      = "above_threshold"
    period    = "5m"
    threshold = 10
  }

  integration_ids = [fastly_integration.example.id]
}
```

## Import

Fastly Alerts can be imported using their ID, e.g.

```sh
$ terraform import fastly_alert.example xxxxxxxxxxxxxxxxxxxx
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `evaluation_strategy` (Block List, Min: 1, Max: 1) Criteria on how to alert. (see [below for nested schema](#nestedblock--evaluation_strategy))
- `metric` (String) The metric name to alert on for a specific source: [domains](https://developer.fastly.com/reference/api/metrics-stats/domain-inspector/historical), [origins](https://developer.fastly.com/reference/api/metrics-stats/origin-inspector/historical), or [stats](https://developer.fastly.com/reference/api/metrics-stats/historical-stats).
- `name` (String) The name of the alert.
- `source` (String) The source where the metric comes from. One of: `domains`, `origins`, `stats`.

### Optional

- `description` (String) Additional text that is included in the alert notification.
- `dimensions` (Block List, Max: 1) More filters depending on the source type. (see [below for nested schema](#nestedblock--dimensions))
- `integration_ids` (Set of String) List of integrations used to notify when alert fires.
- `service_id` (String) The service which the alert monitors. Optional when using `stats` as the `source`.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--evaluation_strategy"></a>
### Nested Schema for `evaluation_strategy`

Required:

- `period` (String) The length of time to evaluate whether the conditions have been met. The data is polled every minute. One of: `2m`, `3m`, `5m`, `15m`, `30m`.
- `threshold` (Number) Threshold used to alert.
- `type` (String) Type of strategy to use to evaluate. One of: `above_threshold`, `all_above_threshold`, `below_threshold`, `percent_absolute`, `percent_decrease`, `percent_increase`.

Optional:

- `ignore_below` (Number) Threshold for the denominator value used in evaluations that calculate a rate or ratio. Usually used to filter out noise.


<a id="nestedblock--dimensions"></a>
### Nested Schema for `dimensions`

Optional:

- `domains` (Set of String) Names of a subset of domains that the alert monitors.
- `origins` (Set of String) Addresses of a subset of backends that the alert monitors.
