Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.devhelm.io/llms.txt

Use this file to discover all available pages before exploring further.

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
  })

  assertions {
    type   = "status_code"
    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
authobjectHTTP authentication. Pick exactly one of bearer, basic, header, or api_key; each variant takes a vault_secret_id (UUID of a devhelm_secret). header and api_key also require header_name.

Computed attributes

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

assertions block

Repeatable block for pass/fail criteria. The block name is assertions (plural); repeat it once per assertion:
AttributeTypeRequiredDescription
typestringYesAssertion type discriminator in snake_case wire format. Supported values: status_code, response_time, body_contains, header_value, dns_resolves, ssl_expiry, tcp_connects
configstring (JSON)YesAssertion configuration as JSON; the inner type field is omitted (set via the sibling type attribute). Field names inside config are camelCase, e.g. { expected = 200, operator = "equals" } for status_code or { thresholdMs = 500 } for response_time
severitystringfail or warn (default: fail)

incident_policy attribute

Single nested attribute (use = assignment, not a block) controlling confirmation and recovery behavior. Omit it entirely to adopt server defaults; supplying any field overrides the policy in full.
AttributeTypeRequiredDescription
confirmation_typestringConfirmation 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
trigger_ruleslist of objectsRules that determine when failures escalate to incidents
trigger_rules[*] object:
AttributeTypeRequiredDescription
typestringYesconsecutive_failures, failures_in_window, or response_time
severitystringYesdown or degraded
scopestringper_region or any_region
countnumberFailure count threshold (1–10)
window_minutesnumberTime window for failures_in_window
threshold_msnumberResponse time threshold for response_time
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
  })

  assertions {
    type   = "status_code"
    config = jsonencode({ expected = 200, operator = "equals" })
  }

  assertions {
    type     = "response_time"
    config   = jsonencode({ thresholdMs = 2000 })
    severity = "warn"
  }

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

    trigger_rules = [
      {
        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.