Skip to main content
The devhelm_monitor resource creates and manages monitors of any type. Configure assertions, incident policies, and scheduling in HCL.

Basic example

resource "devhelm_monitor" "api_health" {
  name              = "API Health"
  type              = "HTTP"
  frequency_seconds = 60
  regions           = ["us-east", "eu-west"]

  config = jsonencode({
    url       = "https://api.example.com/health"
    method    = "GET"
    verifyTls = true
  })

  assertion {
    type   = "StatusCodeAssertion"
    config = jsonencode({ expected = "200", operator = "equals" })
  }
}

Arguments

Top-level

AttributeTypeRequiredDescription
namestringYesHuman-readable name (also used as import ID)
typestringYesMonitor type: HTTP, DNS, TCP, ICMP, HEARTBEAT, MCP_SERVER. Forces replacement on change.
configstring (JSON)YesType-specific configuration as JSON
frequency_secondsnumberCheck frequency in seconds (30–86400)
enabledboolWhether the monitor is active (default: true)
regionslist(string)Probe regions
environment_idstringEnvironment ID for variable substitution
alert_channel_idslist(string)Alert channel IDs to notify
tag_idslist(string)Tag IDs to attach
authstring (JSON)Authentication configuration as JSON (sensitive)

Computed attributes

AttributeDescription
idMonitor ID
ping_urlHeartbeat ping URL (only set for HEARTBEAT type)

assertion block

Repeatable block for pass/fail criteria:
AttributeTypeRequiredDescription
typestringYesAssertion type (e.g., StatusCodeAssertion, ResponseTimeAssertion)
configstring (JSON)YesAssertion configuration as JSON
severitystringfail or warn (default: fail)

incident_policy block

At most one block. Controls trigger, confirmation, and recovery behavior:
AttributeTypeRequiredDescription
confirmation_typestringYesConfirmation strategy (e.g., multi_region)
min_regions_failingnumberMinimum failing regions to confirm
max_wait_secondsnumberMaximum confirmation wait time
consecutive_successesnumberConsecutive passes required for recovery
min_regions_passingnumberMinimum passing regions for recovery
cooldown_minutesnumberMinutes before auto-resolving
Nested trigger_rule block (inside incident_policy):
AttributeTypeRequiredDescription
typestringYesconsecutive_failures, failures_in_window, or response_time
severitystringYesdown or degraded
scopestringper_region or any_region
countnumberFailure count threshold
window_minutesnumberTime window for failures_in_window
threshold_msnumberResponse time threshold
aggregation_typestringall_exceed, average, p95, max

Config by monitor type

The config attribute accepts JSON. The shape depends on type:
config = jsonencode({
  url           = "https://api.example.com/health"
  method        = "GET"
  verifyTls     = true
  customHeaders = { Accept = "application/json" }
})

Full example with assertions and incident policy

resource "devhelm_monitor" "api_health" {
  name              = "API Health"
  type              = "HTTP"
  frequency_seconds = 60
  enabled           = true
  regions           = ["us-east", "eu-west"]

  config = jsonencode({
    url       = "https://api.example.com/health"
    method    = "GET"
    verifyTls = true
  })

  assertion {
    type   = "StatusCodeAssertion"
    config = jsonencode({ expected = "200", operator = "equals" })
  }

  assertion {
    type     = "ResponseTimeAssertion"
    config   = jsonencode({ thresholdMs = 2000 })
    severity = "warn"
  }

  incident_policy {
    confirmation_type   = "multi_region"
    min_regions_failing = 2
    max_wait_seconds    = 120
    consecutive_successes = 2

    trigger_rule {
      type     = "consecutive_failures"
      severity = "down"
      scope    = "per_region"
      count    = 3
    }
  }

  tag_ids           = [devhelm_tag.production.id]
  alert_channel_ids = [devhelm_alert_channel.slack.id]
}

Import

terraform import devhelm_monitor.api_health "API Health"
Import uses the monitor name as the identifier.

Next steps

Alert channels

devhelm_alert_channel resource reference.

Tags

devhelm_tag resource reference.

Data sources

Reference existing resources without managing them.