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
You can get your instance name and Oodle API key from Settings
-> View API Key
in the Oodle UI. E.g.
if your deployment URL is https://us1.oodle.ai/
, you can go to https://us1.oodle.ai/settings/viewApiKey=true
to access this information.
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"
}
}
notification_policy_id = oodle_notification_policy.test1.id
}
Apply terraform configuration
terraform init
terraform apply