uptime_alert
Manages an Uptime monitoring alert. Alerts define conditions that trigger notifications through one or more channels when a check detects an issue.
At least one channel required
Every alert must have at least one channel block. Channels define where notifications are sent (email, Slack, Discord, PagerDuty, or webhook).
Consecutive Failures Example
Alert after a specified number of consecutive check failures.
resource "uptime_alert" "api_down" {
check_id = uptime_check.api_health.id
name = "API Down"
condition_type = "consecutive_failures"
consecutive_failures_config {
count = 3
}
channel {
type = "email"
target = "ops@example.com"
}
channel {
type = "slack"
target = "https://hooks.slack.com/services/T00/B00/xxx"
}
}Threshold Example
Alert when a metric crosses a threshold (e.g., response time exceeds 2 seconds).
resource "uptime_alert" "api_slow" {
check_id = uptime_check.api_health.id
name = "API Response Time High"
condition_type = "threshold"
threshold_config {
metric = "response_time_ms"
operator = "gt"
value = 2000
}
channel {
type = "email"
target = "ops@example.com"
}
}SSL Expiry Example
Alert before an SSL certificate expires.
resource "uptime_alert" "ssl_expiry" {
check_id = uptime_check.api_security.id
name = "SSL Certificate Expiring"
condition_type = "ssl_expiry"
ssl_expiry_config {
days_before = 14
}
channel {
type = "email"
target = "security@example.com"
}
}Status Code Example
Alert when specific HTTP status codes are returned.
resource "uptime_alert" "bad_status" {
check_id = uptime_check.api_health.id
name = "Unexpected Status Code"
condition_type = "status_code"
status_code_config {
excluded_codes = [500, 502, 503]
}
channel {
type = "webhook"
target = "https://hooks.example.com/alerts"
config = {
method = "POST"
}
}
}Top-Level Argument Reference
| Name | Type | Status | Description |
|---|---|---|---|
id | String | Computed | Server-generated UUID of the alert. |
check_id | String | Required | ID of the check this alert is attached to. Changing this forces a new resource. |
name | String | Required | Display name of the alert. |
condition_type | String | Required | Type of alert condition. One of: "threshold", "consecutive_failures", "ssl_expiry", "status_code". Changing this forces a new resource. |
enabled | Bool | Optional + Computed | Whether the alert is enabled.Default: true |
created_at | String | Computed | Timestamp when the alert was created. |
threshold_config
Configuration for threshold-based alert conditions.
| Name | Type | Status | Description |
|---|---|---|---|
metric | String | Required | Metric to evaluate (e.g. "response_time_ms"). |
operator | String | Required | Comparison operator. One of: "gt", "lt", "gte", "lte". |
value | Float64 | Required | Threshold value for comparison. |
consecutive_failures_config
Configuration for consecutive failure alert conditions.
| Name | Type | Status | Description |
|---|---|---|---|
count | Int64 | Required | Number of consecutive failures to trigger the alert. |
ssl_expiry_config
Configuration for SSL expiry alert conditions.
| Name | Type | Status | Description |
|---|---|---|---|
days_before | Int64 | Required | Number of days before SSL expiry to trigger the alert. |
status_code_config
Configuration for status code alert conditions.
| Name | Type | Status | Description |
|---|---|---|---|
excluded_codes | List(Int64) | Required | List of HTTP status codes that should trigger the alert. |
channel
Notification channels for the alert. At least one channel is required.
| Name | Type | Status | Description |
|---|---|---|---|
type | String | Required | Channel type. One of: "email", "slack", "discord", "pagerduty", "webhook". |
target | String | Required | Channel target (e.g. email address, webhook URL, Slack channel). |
config | Map(String) | Optional | Additional channel-specific configuration. |
Import
Existing alerts can be imported using their UUID.
terraform import uptime_alert.api_down <alert-uuid>