Back to .md Directory

generated by https://github.com/hashicorp/terraform-plugin-docs

page_title: "checkly_check Resource - terraform-provider-checkly"

May 2, 2026
0 downloads
0 views
ai
View source

generated by https://github.com/hashicorp/terraform-plugin-docs

page_title: "checkly_check Resource - terraform-provider-checkly" subcategory: "" description: |- Checks allows you to monitor key webapp flows, backend API's and set up alerting, so you get a notification when things break or slow down.

checkly_check (Resource)

Checks allows you to monitor key webapp flows, backend API's and set up alerting, so you get a notification when things break or slow down.

Example Usage

# Basic API Check
resource "checkly_check" "example_check" {
  name                      = "Example check"
  type                      = "API"
  activated                 = true
  should_fail               = false
  frequency                 = 1
  use_global_alert_settings = true

  locations = [
    "us-west-1"
  ]

  request {
    url              = "https://api.example.com/"
    follow_redirects = true
    skip_ssl         = false
    assertion {
      source     = "STATUS_CODE"
      comparison = "EQUALS"
      target     = "200"
    }
  }
}

# A more complex example using more assertions and setting alerts
resource "checkly_check" "example_check_2" {
  name                   = "Example API check 2"
  type                   = "API"
  activated              = true
  should_fail            = true
  frequency              = 1
  degraded_response_time = 5000
  max_response_time      = 10000

  locations = [
    "us-west-1",
    "ap-northeast-1",
    "ap-south-1",
  ]

  alert_settings {
    escalation_type = "RUN_BASED"

    run_based_escalation {
      failed_run_threshold = 1
    }

    reminders {
      amount = 1
    }
  }

  retry_strategy {
    type                 = "FIXED"
    base_backoff_seconds = 60
    max_duration_seconds = 600
    max_retries          = 3
    same_region          = false
  }

  request {
    follow_redirects = true
    skip_ssl         = false
    url              = "http://api.example.com/"

    query_parameters = {
      search = "foo"
    }

    headers = {
      X-Bogus = "bogus"
    }

    assertion {
      source     = "JSON_BODY"
      property   = "code"
      comparison = "HAS_VALUE"
      target     = "authentication.failed"
    }

    assertion {
      source     = "STATUS_CODE"
      property   = ""
      comparison = "EQUALS"
      target     = "401"
    }

    basic_auth {
      username = ""
      password = ""
    }
  }
}

# Basic Browser  Check
resource "checkly_check" "browser_check_1" {
  name                      = "Example check"
  type                      = "BROWSER"
  activated                 = true
  should_fail               = false
  frequency                 = 10
  use_global_alert_settings = true
  locations = [
    "us-west-1"
  ]

  runtime_id = "2023.02"

  script = <<EOT
const { expect, test } = require('@playwright/test')

test.use({ actionTimeout: 10000 })

test('visit page and take screenshot', async ({ page }) => {
    const response = await page.goto(process.env.ENVIRONMENT_URL || 'https://checklyhq.com')
    await page.screenshot({ path: 'screenshot.jpg' })
    expect(response.status(), 'should respond with correct status code').toBeLessThan(400)
})
EOT
}

# Connection checks with alert channels
resource "checkly_alert_channel" "email_ac1" {
  email {
    address = "info1@example.com"
  }
}

resource "checkly_alert_channel" "email_ac2" {
  email {
    address = "info2@example.com"
  }
}

resource "checkly_check" "example_check" {
  name = "Example check"
  # ...

  alert_channel_subscription {
    channel_id = checkly_alert_channel.email_ac1.id
    activated  = true
  }

  alert_channel_subscription {
    channel_id = checkly_alert_channel.email_ac2.id
    activated  = true
  }
}

# An alternative syntax for add the script is by referencing an external file
# data "local_file" "browser_script" {
#   filename = "${path.module}/browser-script.js"
# }

# resource "checkly_check" "browser_check_1" {
#   name                      = "Example check"
#   type                      = "BROWSER"
#   activated                 = true
#   should_fail               = false
#   frequency                 = 10
#   use_global_alert_settings = true
#   locations = [
#     "us-west-1"
#   ]

#   runtime_id = "2023.02"
#   script = data.local_file.browser_script.content
# }
<!-- schema generated by tfplugindocs -->

Schema

Required

  • activated (Boolean) Determines if the check is running or not. Possible values true, and false.
  • frequency (Number) Controls how often the check should run. Defined in minutes. The allowed values are 0 (high frequency - use frequency_offset to define the actual frequency), 1 (1 minute), 2 (2 minutes), 5 (5 minutes), 10 (10 minutes), 15 (15 minutes), 30 (30 minutes), 60 (1 hour), 120 (2 hours), 180 (3 hours), 360 (6 hours), 720 (12 hours) and 1440 (24 hours).
  • name (String) The name of the check.
  • type (String) The type of the check. Possible values are API, BROWSER, and MULTI_STEP.

Optional

  • alert_channel_subscription (Block Set) An array of channel IDs and whether they're activated or not. If you don't set at least one alert channel subscription for your check, we won't be able to alert you even if it starts failing. (see below for nested schema)
  • alert_settings (Block List, Max: 1) Determines the alert escalation policy for the check. (see below for nested schema)
  • degraded_response_time (Number) The response time in milliseconds starting from which a check should be considered degraded. Possible values are between 0 and 30000. (Default 15000).
  • description (String) A description of the check.
  • double_check (Boolean, Deprecated) Setting this to true will trigger a retry when a check fails from the failing region and another, randomly selected region before marking the check as failed. (Default false).
  • environment_variable (Block List) Insert environment variables into the runtime environment. Only relevant for browser checks. Use global environment variables whenever possible. (see below for nested schema)
  • environment_variables (Map of String, Deprecated) Key/value pairs of environment variables to insert into the runtime environment.
  • frequency_offset (Number) Only relevant when type is API. When frequency is 0 (high frequency), frequency_offset is required and it alone controls how often the monitor should run. Defined in seconds. The allowed values are 0 (disabled - use frequency to define the actual frequency), 10 (10 seconds), 20 (20 seconds) and 30 (30 seconds).
  • group_id (Number) The id of the check group this check is part of.
  • group_order (Number) The position of this check in a check group. It determines in what order checks are run when a group is triggered from the API or from CI/CD.
  • local_setup_script (String) A valid piece of Node.js code to run in the setup phase.
  • local_teardown_script (String) A valid piece of Node.js code to run in the teardown phase.
  • locations (Set of String) An array of one or more data center locations where to run the this check. (Default ["us-east-1"])
  • max_response_time (Number) The response time in milliseconds starting from which a check should be considered failing. Possible values are between 0 and 30000. (Default 30000).
  • muted (Boolean) Determines if any notifications will be sent out when a check fails/degrades/recovers.
  • private_locations (Set of String) An array of one or more private locations slugs.
  • request (Block Set, Max: 1) An API check might have one request config. (see below for nested schema)
  • retry_strategy (Block List, Max: 1) A strategy for retrying failed check/monitor runs. (see below for nested schema)
  • run_parallel (Boolean) Determines if the check should run in all selected locations in parallel or round-robin.
  • runtime_id (String) The id of the runtime to use for this check.
  • script (String) A valid piece of Node.js JavaScript code describing a browser interaction with the Puppeteer/Playwright framework or a reference to an external JavaScript file.
  • setup_snippet_id (Number) An ID reference to a snippet to use in the setup phase of an API check.
  • should_fail (Boolean) Allows to invert the behaviour of when a check is considered to fail. Allows for validating error status like 404.
  • ssl_check (Boolean, Deprecated) Determines if the SSL certificate should be validated for expiry.
  • ssl_check_domain (String) A valid fully qualified domain name (FQDN) to check its SSL certificate.
  • tags (Set of String) A list of tags for organizing and filtering checks.
  • teardown_snippet_id (Number) An ID reference to a snippet to use in the teardown phase of an API check.
  • trigger_incident (Block Set, Max: 1) Create and resolve an incident based on the alert configuration. Useful for status page automation. (see below for nested schema)
  • use_global_alert_settings (Boolean) When true, the account level alert settings will be used, not the alert setting defined on this check.

Read-Only

  • id (String) The ID of this resource.

<a id="nestedblock--alert_channel_subscription"></a>

Nested Schema for alert_channel_subscription

Required:

  • activated (Boolean) Whether an alert should be sent to this channel.
  • channel_id (Number) The ID of the alert channel.

<a id="nestedblock--alert_settings"></a>

Nested Schema for alert_settings

Optional:

  • escalation_type (String) Determines the type of escalation to use. Possible values are RUN_BASED and TIME_BASED. (Default RUN_BASED).
  • parallel_run_failure_threshold (Block List) Configuration for parallel run failure threshold. (see below for nested schema)
  • reminders (Block List) Defines how often to send reminder notifications after initial alert. (see below for nested schema)
  • run_based_escalation (Block List) Configuration for run-based escalation. (see below for nested schema)
  • ssl_certificates (Block Set, Deprecated) (see below for nested schema)
  • time_based_escalation (Block List) Configuration for time-based escalation. (see below for nested schema)

<a id="nestedblock--alert_settings--parallel_run_failure_threshold"></a>

Nested Schema for alert_settings.parallel_run_failure_threshold

Optional:

  • enabled (Boolean) Whether parallel run failure threshold is enabled. Only applies if the check is scheduled for multiple locations in parallel. (Default false).
  • percentage (Number) Percentage of runs that must fail to trigger alert. Possible values are 10, 20, 30, 40, 50, 60, 70, 80, 90, and 100. (Default 10).

<a id="nestedblock--alert_settings--reminders"></a>

Nested Schema for alert_settings.reminders

Optional:

  • amount (Number) Number of reminder notifications to send. Possible values are 0, 1, 2, 3, 4, 5, and 100000 (0 to disable, 100000 for unlimited). (Default 0).
  • interval (Number) Interval between reminder notifications in minutes. Possible values are 5, 10, 15, and 30. (Default 5).

<a id="nestedblock--alert_settings--run_based_escalation"></a>

Nested Schema for alert_settings.run_based_escalation

Optional:

  • failed_run_threshold (Number) Send an alert notification after the given number of consecutive check runs have failed. Possible values are between 1 and 5. (Default 1).

<a id="nestedblock--alert_settings--ssl_certificates"></a>

Nested Schema for alert_settings.ssl_certificates

Optional:

  • alert_threshold (Number) No longer available.
  • enabled (Boolean) No longer available.

<a id="nestedblock--alert_settings--time_based_escalation"></a>

Nested Schema for alert_settings.time_based_escalation

Optional:

  • minutes_failing_threshold (Number) Send an alert notification after the check has been failing for the given amount of time (in minutes). Possible values are 5, 10, 15, and 30. (Default 5).

<a id="nestedblock--environment_variable"></a>

Nested Schema for environment_variable

Required:

  • key (String) The name of the environment variable or secret.
  • value (String) The value of the environment variable or secret.

Optional:

  • locked (Boolean) If true, the value is not shown by default, but it can be accessed. (Default false).
  • secret (Boolean) If true, the value will never be visible. (Default false).

<a id="nestedblock--request"></a>

Nested Schema for request

Required:

  • url (String)

Optional:

  • assertion (Block Set) A request can have multiple assertions. (see below for nested schema)
  • basic_auth (Block Set, Max: 1) Set up HTTP basic authentication (username & password). (see below for nested schema)
  • body (String) The body of the request.
  • body_type (String) The Content-Type header of the request. Possible values NONE, JSON, FORM, RAW, and GRAPHQL.
  • follow_redirects (Boolean)
  • headers (Map of String)
  • ip_family (String) IP Family to be used when executing the api check. The value can be either IPv4 or IPv6.
  • method (String) The HTTP method to use for this API check. Possible values are GET, POST, PUT, HEAD, DELETE, PATCH. (Default GET).
  • query_parameters (Map of String)
  • skip_ssl (Boolean)

<a id="nestedblock--request--assertion"></a>

Nested Schema for request.assertion

Required:

  • comparison (String) The type of comparison to be executed between expected and actual value of the assertion. Possible values EQUALS, NOT_EQUALS, HAS_KEY, NOT_HAS_KEY, HAS_VALUE, NOT_HAS_VALUE, IS_EMPTY, NOT_EMPTY, GREATER_THAN, LESS_THAN, CONTAINS, NOT_CONTAINS, IS_NULL, and NOT_NULL.
  • source (String) The source of the asserted value. Possible values STATUS_CODE, JSON_BODY, HEADERS, TEXT_BODY, and RESPONSE_TIME.

Optional:

  • property (String)
  • target (String)

<a id="nestedblock--request--basic_auth"></a>

Nested Schema for request.basic_auth

Required:

  • password (String)
  • username (String)

<a id="nestedblock--retry_strategy"></a>

Nested Schema for retry_strategy

Required:

  • type (String) Determines which type of retry strategy to use. Possible values are FIXED, LINEAR, EXPONENTIAL, SINGLE_RETRY, and NO_RETRIES.

Optional:

  • base_backoff_seconds (Number) The number of seconds to wait before the first retry attempt. (Default 60).
  • max_duration_seconds (Number) The total amount of time to continue retrying the check/monitor (maximum 600 seconds). Available when type is FIXED, LINEAR, or EXPONENTIAL. (Default 600).
  • max_retries (Number) The maximum number of times to retry the check/monitor. Value must be between 1 and 10. Available when type is FIXED, LINEAR, or EXPONENTIAL. (Default 2).
  • only_on (Block List, Max: 1) Apply the retry strategy only if the defined conditions match. (see below for nested schema)
  • same_region (Boolean) Whether retries should be run in the same region as the initial check/monitor run. (Default true).

<a id="nestedblock--retry_strategy--only_on"></a>

Nested Schema for retry_strategy.only_on

Optional:

  • network_error (Boolean) When true, retry only if the cause of the failure is a network error. (Default false).

<a id="nestedblock--trigger_incident"></a>

Nested Schema for trigger_incident

Required:

  • description (String) A detailed description of the incident.
  • name (String) The name of the incident.
  • notify_subscribers (Boolean) Whether to notify subscribers when the incident is triggered.
  • service_id (String) The status page service that this incident will be associated with.
  • severity (String) The severity level of the incident. Possible values are MINOR, MEDIUM, MAJOR, and CRITICAL.

Related Documents