Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fastly_alert): implement resource and documentation #810

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions docs/resources/alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
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.example.com"
}

force_destroy = true
}

resource "fastly_alert" "example" {
name = "my_vcl_service error rate"
service_id = fastly_service_vcl.example.id
source = "stats"
metric = "status_5xx_rate"

evaluation_strategy {
type = "above_threshold"
period = "5m"
threshold = 0.1
}
}
```

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

### Required

- `evaluation_strategy` (Block List, Min: 1, Max: 1) Evaluation strategy for the Alert. (see [below for nested schema](#nestedblock--evaluation_strategy))
- `metric` (String) The name of the metric to monitor for Alert evaluation. For detailed information on metrics available for monitoring, see [Fastly Alerts API Documentation](https://developer.fastly.com/reference/api/observability/alerts/definition/).
- `name` (String) Summary text of the Alert.
- `service_id` (String) ID of the Fastly Service that the Alert monitors.
- `source` (String) The metric source. One of: `stats`, `origins`, `domains`.

### Optional

- `description` (String) Text body included in Alert notifications.
- `dimensions` (Block List, Max: 1) Dimension filters applied to the metric. (see [below for nested schema](#nestedblock--dimensions))
- `integration_ids` (Set of String) Set of IDs of integrations that Alert notifications will be sent to.

### Read-Only

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darin-nee There is also object = "definition" that is returned in the response, also read-only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's in the API response and elided in the Terraform schema.


<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: `5m`, `15m`, `30m`.
- `threshold` (Number) Threshold used to trigger.
- `type` (String) Type of strategy to use to evaluate. One of: `above_threshold`, `below_threshold`.


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

Optional:

- `domains` (Set of String) Names of a subset of domains defined on the service that the Alert monitors.
- `origins` (Set of String) Addresses of a subset of backends defined on the service that the Alert monitors.
15 changes: 15 additions & 0 deletions examples/resources/alert_basic_usage.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "fastly_service_vcl" "myservice" {
#...
}

resource "fastly_alert" "demo" {
name = "myservice error rate"
service_id = fastly_service_vcl.myservice.id
source = "stats"
metric = "status_5xx_rate"
evaluation_strategy {
type = "above_threshold"
period = "5m"
threshold = 0.1
}
}
1 change: 1 addition & 0 deletions fastly/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func Provider() *schema.Provider {
"fastly_waf_rules": dataSourceFastlyWAFRules(),
},
ResourcesMap: map[string]*schema.Resource{
"fastly_alert": resourceFastlyAlert(),
"fastly_configstore": resourceFastlyConfigStore(),
"fastly_configstore_entries": resourceFastlyConfigStoreEntries(),
"fastly_kvstore": resourceFastlyKVStore(),
Expand Down
Loading
Loading