pagerduty_ruleset_rule

An event rule allows you to set actions that should be taken on events that meet your designated rule criteria.

Example Usage

resource "pagerduty_team" "foo" {
  name = "Engineering (Seattle)"
}

resource "pagerduty_ruleset" "foo" {
  name = "Primary Ruleset"
  team {
    id = pagerduty_team.foo.id
  }
}

# The pagerduty_ruleset_rule.foo rule defined below
# repeats daily from 9:30am - 11:30am using the America/New_York timezone.
# Thus it requires a time_static instance to represent 9:30am on an arbitrary date in that timezone.
# April 11th, 2019 was EDT (UTC-4) https://www.timeanddate.com/worldclock/converter.html?iso=20190411T133000&p1=179
resource "time_static" "eastern_time_at_0930" {
  rfc3339 = "2019-04-11T09:30:00-04:00"
}

resource "pagerduty_ruleset_rule" "foo" {
  ruleset  = pagerduty_ruleset.foo.id
  position = 0
  disabled = "false"
  time_frame {
    scheduled_weekly {
      # Every Tuesday, Thursday, & Saturday
      weekdays = [2, 4, 6]
      # Starting at 9:30am
      start_time = time_static.eastern_time_at_0930.unix * 1000
      # Until 11:30am (2 hours later)
      duration = 2 * 60 * 60 * 1000
      # in this timezone
      # (either EST or EDT depending on when your event arrives)
      timezone = "America/New_York"
    }
  }
  conditions {
    operator = "and"
    subconditions {
      operator = "contains"
      parameter {
        value = "disk space"
        path  = "payload.summary"
      }
    }
    subconditions {
      operator = "contains"
      parameter {
        value = "db"
        path  = "payload.source"
      }
    }
  }
  variable {
    type = "regex"
    name = "Src"
    parameters {
      value = "(.*)"
      path  = "payload.source"
    }
  }
  actions {
    route {
      value = pagerduty_service.foo.id
    }
    severity {
      value = "warning"
    }
    annotate {
      value = "From Terraform"
    }
    extractions {
      target = "dedup_key"
      source = "details.host"
      regex  = "(.*)"
    }
    extractions {
      target   = "summary"
      template = "Warning: Disk Space Low on {{Src}}"
    }
  }
}

resource "pagerduty_ruleset_rule" "catch_all" {
  ruleset  = pagerduty_ruleset.foo.id
  position = 1
  catch_all = true
  actions {
    annotate {
      value = "From Terraform"
    }
    suppress {
      value = true
    }
  }
}

Argument Reference

The following arguments are supported:

Conditions (conditions) supports the following:

Sub-Conditions (subconditions) supports the following:

Action (actions) supports the following:

Time Frame (time_frame) supports the following:

Attributes Reference

The following attributes are exported:

Import

Ruleset rules can be imported using the related ruleset ID and the ruleset_rule ID separated by a dot, e.g.

$ terraform import pagerduty_ruleset_rule.main a19cdca1-3d5e-4b52-bfea-8c8de04da243.19acac92-027a-4ea0-b06c-bbf516519601