Google Cloud (Stackdriver) Monitoring Uptime Check Config
This page shows how to write Terraform for Cloud (Stackdriver) Monitoring Uptime Check Config and write them securely.
google_monitoring_uptime_check_config (Terraform)
The Uptime Check Config in Cloud (Stackdriver) Monitoring can be configured in Terraform with the resource name google_monitoring_uptime_check_config. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_monitoring_uptime_check_config" "tfer--projects-002F-wbstack-002F-uptimeCheckConfigs-002F-addshore-002D-alpha-002D-query-002D-service-002D-ui" {
content_matchers {
content = "query-helper-help"
matcher = "CONTAINS_STRING"
}
resource "google_monitoring_uptime_check_config" "http" {
display_name = "01 - Website uptime check [global]"
timeout = "10s"
period = "60s"
http_check {
resource "google_monitoring_uptime_check_config" "my_check" {
display_name = var.name
timeout = var.timeout
period = var.period
http_check {
path = var.healthcheck_path
resource "google_monitoring_uptime_check_config" "http" {
display_name = "1 - Website uptime check [global]"
timeout = "10s"
period = "60s"
http_check {
path = "/"
Parameters
-
display_namerequired - string
A human-friendly name for the uptime check configuration. The display name should be unique within a Stackdriver Workspace in order to make it easier to identify; however, uniqueness is not enforced.
A unique resource name for this UptimeCheckConfig. The format is projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID].
-
periodoptional - string
How often, in seconds, the uptime check is performed. Currently, the only supported values are 60s (1 minute), 300s (5 minutes), 600s (10 minutes), and 900s (15 minutes). Optional, defaults to 300s.
-
projectoptional computed - string -
selected_regionsoptional - list of string
The list of regions from which the check will be run. Some regions contain one location, and others contain more than one. If this field is specified, enough regions to include a minimum of 3 locations must be provided, or an error message is returned. Not specifying this field will result in uptime checks running from all regions.
-
timeoutrequired - string
The maximum amount of time to wait for the request to complete (must be between 1 and 60 seconds). Accepted formats https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration
-
uptime_check_idoptional computed - string
The id of the uptime check
-
content_matcherslist block-
contentrequired - string
String or regex content to match (max 1024 bytes)
-
matcheroptional - string
The type of content matcher that will be applied to the server output, compared to the content string when the check is run. Default value: "CONTAINS_STRING" Possible values: ["CONTAINS_STRING", "NOT_CONTAINS_STRING", "MATCHES_REGEX", "NON_MATCHES_REGEX"]
-
-
http_checklist block-
bodyoptional - string
The request body associated with the HTTP POST request. If contentType is URL_ENCODED, the body passed in must be URL-encoded. Users can provide a Content-Length header via the headers field or the API will do so. If the requestMethod is GET and body is not empty, the API will return an error. The maximum byte size is 1 megabyte. Note - As with all bytes fields JSON representations are base64 encoded. e.g. "foo=bar" in URL-encoded form is "foo%3Dbar" and in base64 encoding is "Zm9vJTI1M0RiYXI=".
-
content_typeoptional - string
The content type to use for the check. Possible values: ["TYPE_UNSPECIFIED", "URL_ENCODED"]
-
headersoptional computed - map from string to string
The list of headers to send as part of the uptime check request. If two headers have the same key and different values, they should be entered as a single header, with the value being a comma-separated list of all the desired values as described at https://www.w3.org/Protocols/rfc2616/rfc2616.txt (page 31). Entering two separate headers with the same key in a Create call will cause the first to be overwritten by the second. The maximum number of headers allowed is 100.
-
mask_headersoptional - bool
Boolean specifying whether to encrypt the header information. Encryption should be specified for any headers related to authentication that you do not wish to be seen when retrieving the configuration. The server will be responsible for encrypting the headers. On Get/List calls, if mask_headers is set to True then the headers will be obscured with **.
-
pathoptional - string
The path to the page to run the check against. Will be combined with the host (specified within the MonitoredResource) and port to construct the full URL. Optional (defaults to "/").
-
portoptional computed - number
The port to the page to run the check against. Will be combined with host (specified within the MonitoredResource) and path to construct the full URL. Optional (defaults to 80 without SSL, or 443 with SSL).
-
request_methodoptional - string
The HTTP request method to use for the check. If set to METHOD_UNSPECIFIED then requestMethod defaults to GET. Default value: "GET" Possible values: ["METHOD_UNSPECIFIED", "GET", "POST"]
-
use_ssloptional - bool
If true, use HTTPS instead of HTTP to run the check.
-
validate_ssloptional - bool
Boolean specifying whether to include SSL certificate validation as a part of the Uptime check. Only applies to checks where monitoredResource is set to uptime_url. If useSsl is false, setting validateSsl to true has no effect.
-
-
monitored_resourcelist block-
labelsrequired - map from string to string
Values for all of the labels listed in the associated monitored resource descriptor. For example, Compute Engine VM instances use the labels "project_id", "instance_id", and "zone".
-
typerequired - string
The monitored resource type. This field must match the type field of a MonitoredResourceDescriptor (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.monitoredResourceDescriptors#MonitoredResourceDescriptor) object. For example, the type of a Compute Engine VM instance is gce_instance. For a list of types, see Monitoring resource types (https://cloud.google.com/monitoring/api/resources) and Logging resource types (https://cloud.google.com/logging/docs/api/v2/resource-list).
-
-
resource_grouplist block-
group_idoptional - string
The group of resources being monitored. Should be the 'name' of a group
-
resource_typeoptional - string
The resource type of the group members. Possible values: ["RESOURCE_TYPE_UNSPECIFIED", "INSTANCE", "AWS_ELB_LOAD_BALANCER"]
-
-
tcp_checklist block-
portrequired - number
The port to the page to run the check against. Will be combined with host (specified within the MonitoredResource) to construct the full URL.
-
-
timeoutssingle block
Explanation in Terraform Registry
This message configures which resources and services to monitor for availability. To get more information about UptimeCheckConfig, see:
- API documentation
- How-to Guides
- Official Documentation
Warning: All arguments including
http_check.auth_info.passwordwill be stored in the raw state as plain-text. Read more about sensitive data in state.
Frequently asked questions
What is Google Cloud (Stackdriver) Monitoring Uptime Check Config?
Google Cloud (Stackdriver) Monitoring Uptime Check Config is a resource for Cloud (Stackdriver) Monitoring of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google Cloud (Stackdriver) Monitoring Uptime Check Config?
For Terraform, the wbstack/deploy, charlesbaer/stackdriver-automation and DNXLabs/terraform-google-stackdriver-uptime source code examples are useful. See the Terraform Example section for further details.