Terraform for alerts
Configure all your alerts, notifiers and notification policies through terraform.
Advantages of managing alerts as code
- They are version-controlled, making changes and rollbacks more transparent and trackable.
- This approach allows you to standardize alert configurations across environments, eliminating manual errors and drift between staging and production. You can apply the same alert configuration across all your deployments / environments.
- Terraform's declarative nature also makes it easy to spin up or tear down alerts alongside your infrastructure, ensuring your monitoring evolves with your stack.
- Integrating alert management into your CI/CD pipeline means faster, more reliable deployments, as your alerts will always align with the infrastructure they monitor.
How
info
Use oodle's Terraform Provider
Prerequisites
To setup Oodle Alerts via Terraform files, you'll need the following values:
OODLE_INSTANCE: Your Oodle instance ID. Go toSettingsicon ->API Keyspage in your Oodle UI to find out. (Oodle UI links: ap1, us1)OODLE_API_KEY: Your Oodle API key for authentication. Go toSettingsicon ->API Keysin your Oodle UI to choose an appropriate key. (Oodle UI links: ap1, us1)
Example usage
terraform {
required_providers {
oodle = {
source = "registry.terraform.io/oodle-ai/oodle"
}
}
}
# These can also be set as environment variables:
# export OODLE_DEPLOYMENT=https://us1.oodle.ai/
# export OODLE_INSTANCE="my-instance"
# export OODLE_API_KEY="my-api-key"
provider "oodle" {
deployment_url = "https://us1.oodle.ai/"
instance = "my-instance"
api_key = "my-api-key"
}
# Example usage of notifier, notification policy and monitor.
# Refer to https://registry.terraform.io/providers/oodle-ai/oodle/latest/docs/resources/notifier
# for schema documentation.
resource "oodle_notifier" "notifier_test1" {
name = "terraform_test_notifier"
type = "pagerduty"
pagerduty_config = {
service_key = "foo"
send_resolved = true
}
}
# Refer to https://registry.terraform.io/providers/oodle-ai/oodle/latest/docs/resources/notification_policy
# for schema documentation.
resource "oodle_notification_policy" "test1" {
name = "terraform_test_policy"
notifiers = {
critical = [oodle_notifier.notifier_test1.id]
}
}
# Refer to https://registry.terraform.io/providers/oodle-ai/oodle/latest/docs/resources/monitor
# for schema documentation.
resource "oodle_monitor" "test1" {
name = "terraform_test"
promql_query = "sum(rate(oober_food_delivery_revenue_usd[3m]))"
conditions = {
critical = {
value = 1210000
operation = ">"
for = "3m"
alert_on_no_data = true
}
}
notification_policy_id = oodle_notification_policy.test1.id
}
Apply terraform configuration
terraform init
terraform apply