521 lines
17 KiB
Markdown
521 lines
17 KiB
Markdown
|
---
|
||
|
layout: "circonus"
|
||
|
page_title: "Circonus: circonus_check"
|
||
|
sidebar_current: "docs-circonus-resource-circonus_check"
|
||
|
description: |-
|
||
|
Manages a Circonus check.
|
||
|
---
|
||
|
|
||
|
# circonus\_check
|
||
|
|
||
|
The ``circonus_check`` resource creates and manages a
|
||
|
[Circonus Check](https://login.circonus.com/resources/api/calls/check_bundle).
|
||
|
|
||
|
~> **NOTE regarding `cirocnus_check` vs a Circonus Check Bundle:** The
|
||
|
`circonus_check` resource is implemented in terms of a
|
||
|
[Circonus Check Bundle](https://login.circonus.com/resources/api/calls/check_bundle).
|
||
|
The `circonus_check` creates a higher-level abstraction over the implementation
|
||
|
of a Check Bundle. As such, the naming and structure does not map 1:1 with the
|
||
|
underlying Circonus API.
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
```
|
||
|
variable api_token {
|
||
|
default = "my-token"
|
||
|
}
|
||
|
|
||
|
resource "circonus_check" "usage" {
|
||
|
name = "Circonus Usage Check"
|
||
|
|
||
|
notes = <<-EOF
|
||
|
A check to extract a usage metric.
|
||
|
EOF
|
||
|
|
||
|
collector {
|
||
|
id = "/broker/1"
|
||
|
}
|
||
|
|
||
|
metric {
|
||
|
name = "${circonus_metric.used.name}"
|
||
|
tags = "${circonus_metric.used.tags}"
|
||
|
type = "${circonus_metric.used.type}"
|
||
|
unit = "${circonus_metric.used.unit}"
|
||
|
}
|
||
|
|
||
|
json {
|
||
|
url = "https://api.circonus.com/v2"
|
||
|
|
||
|
http_headers = {
|
||
|
Accept = "application/json"
|
||
|
X-Circonus-App-Name = "TerraformCheck"
|
||
|
X-Circonus-Auth-Token = "${var.api_token}"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
period = 60
|
||
|
tags = ["source:circonus", "author:terraform"]
|
||
|
timeout = 10
|
||
|
}
|
||
|
|
||
|
resource "circonus_metric" "used" {
|
||
|
name = "_usage`0`_used"
|
||
|
type = "numeric"
|
||
|
unit = "qty"
|
||
|
|
||
|
tags = {
|
||
|
source = "circonus"
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Argument Reference
|
||
|
|
||
|
* `active` - (Optional) Whether or not the check is enabled or not (default
|
||
|
`true`).
|
||
|
|
||
|
* `caql` - (Optional) A [Circonus Analytics Query Language
|
||
|
(CAQL)](https://login.circonus.com/user/docs/CAQL) check. See below for
|
||
|
details on how to configure a `caql` check.
|
||
|
|
||
|
* `cloudwatch` - (Optional) A [CloudWatch
|
||
|
check](https://login.circonus.com/user/docs/Data/CheckTypes/CloudWatch) check.
|
||
|
See below for details on how to configure a `cloudwatch` check.
|
||
|
|
||
|
* `collector` - (Required) A collector ID. The collector(s) that are
|
||
|
responsible for running a `circonus_check`. The `id` can be the Circonus ID
|
||
|
for a Circonus collector (a.k.a. "broker") running in the cloud or an
|
||
|
enterprise collector running in your datacenter. One collection of metrics
|
||
|
will be automatically created for each `collector` specified.
|
||
|
|
||
|
* `http` - (Optional) A poll-based HTTP check. See below for details on how to configure
|
||
|
the `http` check.
|
||
|
|
||
|
* `httptrap` - (Optional) An push-based HTTP check. This check method expects
|
||
|
clients to send a specially crafted HTTP JSON payload. See below for details
|
||
|
on how to configure the `httptrap` check.
|
||
|
|
||
|
* `icmp_ping` - (Optional) An ICMP ping check. See below for details on how to
|
||
|
configure the `icmp_ping` check.
|
||
|
|
||
|
* `json` - (Optional) A JSON check. See below for details on how to configure
|
||
|
the `json` check.
|
||
|
|
||
|
* `metric_limit` - (Optional) Setting a metric limit will tell the Circonus
|
||
|
backend to periodically look at the check to see if there are additional
|
||
|
metrics the collector has seen that we should collect. It will not reactivate
|
||
|
metrics previously collected and then marked as inactive. Values are `0` to
|
||
|
disable, `-1` to enable all metrics or `N+` to collect up to the value `N`
|
||
|
(both `-1` and `N+` can not exceed other account restrictions).
|
||
|
|
||
|
* `mysql` - (Optional) A MySQL check. See below for details on how to configure
|
||
|
the `mysql` check.
|
||
|
|
||
|
* `name` - (Optional) The name of the check that will be displayed in the web
|
||
|
interface.
|
||
|
|
||
|
* `notes` - (Optional) Notes about this check.
|
||
|
|
||
|
* `period` - (Optional) The period between each time the check is made in
|
||
|
seconds.
|
||
|
|
||
|
* `postgresql` - (Optional) A PostgreSQL check. See below for details on how to
|
||
|
configure the `postgresql` check.
|
||
|
|
||
|
* `metric` - (Required) A list of one or more `metric` configurations. All
|
||
|
metrics obtained from this check instance will be available as individual
|
||
|
metric streams. See below for a list of supported `metric` attrbutes.
|
||
|
|
||
|
* `tags` - (Optional) A list of tags assigned to this check.
|
||
|
|
||
|
* `target` - (Required) A string containing the location of the thing being
|
||
|
checked. This value changes based on the check type. For example, for an
|
||
|
`http` check type this would be the URL you're checking. For a DNS check it
|
||
|
would be the hostname you wanted to look up.
|
||
|
|
||
|
* `tcp` - (Optional) A TCP check. See below for details on how to configure the
|
||
|
`tcp` check (includes TLS support).
|
||
|
|
||
|
* `timeout` - (Optional) A floating point number representing the maximum number
|
||
|
of seconds this check should wait for a result. Defaults to `10.0`.
|
||
|
|
||
|
## Supported `metric` Attributes
|
||
|
|
||
|
The following attributes are available within a `metric`.
|
||
|
|
||
|
* `active` - (Optional) Whether or not the metric is active or not. Defaults to `true`.
|
||
|
* `name` - (Optional) The name of the metric. A string containing freeform text.
|
||
|
* `tags` - (Optional) A list of tags assigned to the metric.
|
||
|
* `type` - (Required) A string containing either `numeric`, `text`, `histogram`, `composite`, or `caql`.
|
||
|
* `units` - (Optional) The unit of measurement the metric represents (e.g., bytes, seconds, milliseconds). A string containing freeform text.
|
||
|
|
||
|
## Supported Check Types
|
||
|
|
||
|
Circonus supports a variety of different checks. Each check type has its own
|
||
|
set of options that must be configured. Each check type conflicts with every
|
||
|
other check type (i.e. a `circonus_check` configured for a `json` check will
|
||
|
conflict with all other check types, therefore a `postgresql` check must be a
|
||
|
different `circonus_check` resource).
|
||
|
|
||
|
### `caql` Check Type Attributes
|
||
|
|
||
|
* `query` - (Required) The [CAQL
|
||
|
Query](https://login.circonus.com/user/docs/caql_reference) to run.
|
||
|
|
||
|
Available metrics depend on the payload returned in the `caql` check. See the
|
||
|
[`caql` check type](https://login.circonus.com/resources/api/calls/check_bundle) for
|
||
|
additional details.
|
||
|
|
||
|
### `cloudwatch` Check Type Attributes
|
||
|
|
||
|
* `api_key` - (Required) The AWS access key. If this value is not explicitly
|
||
|
set, this value is populated by the environment variable `AWS_ACCESS_KEY_ID`.
|
||
|
|
||
|
* `api_secret` - (Required) The AWS secret key. If this value is not explicitly
|
||
|
set, this value is populated by the environment variable `AWS_SECRET_ACCESS_KEY`.
|
||
|
|
||
|
* `dimmensions` - (Required) A map of the CloudWatch dimmensions to include in
|
||
|
the check.
|
||
|
|
||
|
* `metric` - (Required) A list of metric names to collect in this check.
|
||
|
|
||
|
* `namespace` - (Required) The namespace to pull parameters from.
|
||
|
|
||
|
* `url` - (Required) The AWS URL to pull from. This should be set to the
|
||
|
region-specific endpoint (e.g. prefer
|
||
|
`https://monitoring.us-east-1.amazonaws.com` over
|
||
|
`https://monitoring.amazonaws.com`).
|
||
|
|
||
|
* `version` - (Optional) The version of the Cloudwatch API to use. Defaults to
|
||
|
`2010-08-01`.
|
||
|
|
||
|
Available metrics depend on the payload returned in the `cloudwatch` check. See the
|
||
|
[`cloudwatch` check type](https://login.circonus.com/resources/api/calls/check_bundle) for
|
||
|
additional details. The `circonus_check` `period` attribute must be set to
|
||
|
either `60s` or `300s` for CloudWatch metrics.
|
||
|
|
||
|
Example CloudWatch check (partial metrics collection):
|
||
|
|
||
|
```
|
||
|
variable "cloudwatch_rds_tags" {
|
||
|
type = "list"
|
||
|
default = [
|
||
|
"app:postgresql",
|
||
|
"app:rds",
|
||
|
"source:cloudwatch",
|
||
|
]
|
||
|
}
|
||
|
|
||
|
resource "circonus_check" "rds_metrics" {
|
||
|
active = true
|
||
|
name = "Terraform test: RDS Metrics via CloudWatch"
|
||
|
notes = "Collect RDS metrics"
|
||
|
period = "60s"
|
||
|
|
||
|
collector {
|
||
|
id = "/broker/1"
|
||
|
}
|
||
|
|
||
|
cloudwatch {
|
||
|
dimmensions = {
|
||
|
DBInstanceIdentifier = "my-db-name",
|
||
|
}
|
||
|
|
||
|
metric = [
|
||
|
"CPUUtilization",
|
||
|
"DatabaseConnections",
|
||
|
]
|
||
|
|
||
|
namespace = "AWS/RDS"
|
||
|
url = "https://monitoring.us-east-1.amazonaws.com"
|
||
|
}
|
||
|
|
||
|
metric {
|
||
|
name = "CPUUtilization"
|
||
|
tags = [ "${var.cloudwatch_rds_tags}" ]
|
||
|
type = "numeric"
|
||
|
unit = "%"
|
||
|
}
|
||
|
|
||
|
metric {
|
||
|
name = "DatabaseConnections"
|
||
|
tags = [ "${var.cloudwatch_rds_tags}" ]
|
||
|
type = "numeric"
|
||
|
unit = "connections"
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
### `http` Check Type Attributes
|
||
|
|
||
|
* `auth_method` - (Optional) HTTP Authentication method to use. When set must
|
||
|
be one of the values `Basic`, `Digest`, or `Auto`.
|
||
|
|
||
|
* `auth_password` - (Optional) The password to use during authentication.
|
||
|
|
||
|
* `auth_user` - (Optional) The user to authenticate as.
|
||
|
|
||
|
* `body_regexp` - (Optional) This regular expression is matched against the body
|
||
|
of the response. If a match is not found, the check will be marked as "bad."
|
||
|
|
||
|
* `ca_chain` - (Optional) A path to a file containing all the certificate
|
||
|
authorities that should be loaded to validate the remote certificate (for TLS
|
||
|
checks).
|
||
|
|
||
|
* `certificate_file` - (Optional) A path to a file containing the client
|
||
|
certificate that will be presented to the remote server (for TLS checks).
|
||
|
|
||
|
* `ciphers` - (Optional) A list of ciphers to be used in the TLS protocol (for
|
||
|
HTTPS checks).
|
||
|
|
||
|
* `code` - (Optional) The HTTP code that is expected. If the code received does
|
||
|
not match this regular expression, the check is marked as "bad."
|
||
|
|
||
|
* `extract` - (Optional) This regular expression is matched against the body of
|
||
|
the response globally. The first capturing match is the key and the second
|
||
|
capturing match is the value. Each key/value extracted is registered as a
|
||
|
metric for the check.
|
||
|
|
||
|
* `headers` - (Optional) A map of the HTTP headers to be sent when executing the
|
||
|
check.
|
||
|
|
||
|
* `key_file` - (Optional) A path to a file containing key to be used in
|
||
|
conjunction with the cilent certificate (for TLS checks).
|
||
|
|
||
|
* `method` - (Optional) The HTTP Method to use. Defaults to `GET`.
|
||
|
|
||
|
* `payload` - (Optional) The information transferred as the payload of an HTTP
|
||
|
request.
|
||
|
|
||
|
* `read_limit` - (Optional) Sets an approximate limit on the data read (`0`
|
||
|
means no limit). Default `0`.
|
||
|
|
||
|
* `redirects` - (Optional) The maximum number of HTTP `Location` header
|
||
|
redirects to follow. Default `0`.
|
||
|
|
||
|
* `url` - (Required) The target for this `json` check. The `url` must include
|
||
|
the scheme, host, port (optional), and path to use
|
||
|
(e.g. `https://app1.example.org/healthz`)
|
||
|
|
||
|
* `version` - (Optional) The HTTP version to use. Defaults to `1.1`.
|
||
|
|
||
|
Available metrics include: `body_match`, `bytes`, `cert_end`, `cert_end_in`,
|
||
|
`cert_error`, `cert_issuer`, `cert_start`, `cert_subject`, `code`, `duration`,
|
||
|
`truncated`, `tt_connect`, and `tt_firstbyte`. See the
|
||
|
[`http` check type](https://login.circonus.com/resources/api/calls/check_bundle) for
|
||
|
additional details.
|
||
|
|
||
|
### `httptrap` Check Type Attributes
|
||
|
|
||
|
* `async_metrics` - (Optional) Boolean value specifies whether or not httptrap
|
||
|
metrics are logged immediately or held until the status message is to be
|
||
|
emitted. Default `false`.
|
||
|
|
||
|
* `secret` - (Optional) Specify the secret with which metrics may be
|
||
|
submitted.
|
||
|
|
||
|
Available metrics depend on the payload returned in the `httptrap` doc. See
|
||
|
the [`httptrap` check type](https://login.circonus.com/resources/api/calls/check_bundle)
|
||
|
for additional details.
|
||
|
|
||
|
### `json` Check Type Attributes
|
||
|
|
||
|
* `auth_method` - (Optional) HTTP Authentication method to use. When set must
|
||
|
be one of the values `Basic`, `Digest`, or `Auto`.
|
||
|
|
||
|
* `auth_password` - (Optional) The password to use during authentication.
|
||
|
|
||
|
* `auth_user` - (Optional) The user to authenticate as.
|
||
|
|
||
|
* `ca_chain` - (Optional) A path to a file containing all the certificate
|
||
|
authorities that should be loaded to validate the remote certificate (for TLS
|
||
|
checks).
|
||
|
|
||
|
* `certificate_file` - (Optional) A path to a file containing the client
|
||
|
certificate that will be presented to the remote server (for TLS checks).
|
||
|
|
||
|
* `ciphers` - (Optional) A list of ciphers to be used in the TLS protocol (for
|
||
|
HTTPS checks).
|
||
|
|
||
|
* `headers` - (Optional) A map of the HTTP headers to be sent when executing the
|
||
|
check.
|
||
|
|
||
|
* `key_file` - (Optional) A path to a file containing key to be used in
|
||
|
conjunction with the cilent certificate (for TLS checks).
|
||
|
|
||
|
* `method` - (Optional) The HTTP Method to use. Defaults to `GET`.
|
||
|
|
||
|
* `port` - (Optional) The TCP Port number to use. Defaults to `81`.
|
||
|
|
||
|
* `read_limit` - (Optional) Sets an approximate limit on the data read (`0`
|
||
|
means no limit). Default `0`.
|
||
|
|
||
|
* `redirects` - (Optional) The maximum number of HTTP `Location` header
|
||
|
redirects to follow. Default `0`.
|
||
|
|
||
|
* `url` - (Required) The target for this `json` check. The `url` must include
|
||
|
the scheme, host, port (optional), and path to use
|
||
|
(e.g. `https://app1.example.org/healthz`)
|
||
|
|
||
|
* `version` - (Optional) The HTTP version to use. Defaults to `1.1`.
|
||
|
|
||
|
Available metrics depend on the payload returned in the `json` doc. See the
|
||
|
[`json` check type](https://login.circonus.com/resources/api/calls/check_bundle) for
|
||
|
additional details.
|
||
|
|
||
|
### `icmp_ping` Check Type Attributes
|
||
|
|
||
|
The `icmp_ping` check requires the `target` top-level attribute to be set.
|
||
|
|
||
|
* `availability` - (Optional) The percentage of ping packets that must be
|
||
|
returned for this measurement to be considered successful. Defaults to
|
||
|
`100.0`.
|
||
|
* `count` - (Optional) The number of ICMP ping packets to send. Defaults to
|
||
|
`5`.
|
||
|
* `interval` - (Optional) Interval between packets. Defaults to `2s`.
|
||
|
|
||
|
Available metrics include: `available`, `average`, `count`, `maximum`, and
|
||
|
`minimum`. See the
|
||
|
[`ping_icmp` check type](https://login.circonus.com/resources/api/calls/check_bundle)
|
||
|
for additional details.
|
||
|
|
||
|
### `mysql` Check Type Attributes
|
||
|
|
||
|
The `mysql` check requires the `target` top-level attribute to be set.
|
||
|
|
||
|
* `dsn` - (Required) The [MySQL DSN/connect
|
||
|
string](https://github.com/go-sql-driver/mysql/blob/master/README.md) to
|
||
|
use to talk to MySQL.
|
||
|
* `query` - (Required) The SQL query to execute.
|
||
|
|
||
|
### `postgresql` Check Type Attributes
|
||
|
|
||
|
The `postgresql` check requires the `target` top-level attribute to be set.
|
||
|
|
||
|
* `dsn` - (Required) The [PostgreSQL DSN/connect
|
||
|
string](https://www.postgresql.org/docs/current/static/libpq-connect.html) to
|
||
|
use to talk to PostgreSQL.
|
||
|
* `query` - (Required) The SQL query to execute.
|
||
|
|
||
|
Available metric names are dependent on the output of the `query` being run.
|
||
|
|
||
|
### `tcp` Check Type Attributes
|
||
|
|
||
|
* `banner_regexp` - (Optional) This regular expression is matched against the
|
||
|
response banner. If a match is not found, the check will be marked as bad.
|
||
|
|
||
|
* `ca_chain` - (Optional) A path to a file containing all the certificate
|
||
|
authorities that should be loaded to validate the remote certificate (for TLS
|
||
|
checks).
|
||
|
|
||
|
* `certificate_file` - (Optional) A path to a file containing the client
|
||
|
certificate that will be presented to the remote server (for TLS checks).
|
||
|
|
||
|
* `ciphers` - (Optional) A list of ciphers to be used in the TLS protocol (for
|
||
|
HTTPS checks).
|
||
|
|
||
|
* `host` - (Required) Hostname or IP address of the host to connect to.
|
||
|
|
||
|
* `key_file` - (Optional) A path to a file containing key to be used in
|
||
|
conjunction with the cilent certificate (for TLS checks).
|
||
|
|
||
|
* `port` - (Required) Integer specifying the port on which the management
|
||
|
interface can be reached.
|
||
|
|
||
|
* `tls` - (Optional) When enabled establish a TLS connection.
|
||
|
|
||
|
Available metrics include: `banner`, `banner_match`, `cert_end`, `cert_end_in`,
|
||
|
`cert_error`, `cert_issuer`, `cert_start`, `cert_subject`, `duration`,
|
||
|
`tt_connect`, `tt_firstbyte`. See the
|
||
|
[`tcp` check type](https://login.circonus.com/resources/api/calls/check_bundle)
|
||
|
for additional details.
|
||
|
|
||
|
Sample `tcp` check:
|
||
|
|
||
|
```
|
||
|
resource "circonus_check" "tcp_check" {
|
||
|
name = "TCP and TLS check"
|
||
|
notes = "Obtains the connect time and TTL for the TLS cert"
|
||
|
period = "60s"
|
||
|
|
||
|
collector {
|
||
|
id = "/broker/1"
|
||
|
}
|
||
|
|
||
|
tcp {
|
||
|
host = "127.0.0.1"
|
||
|
port = 443
|
||
|
tls = true
|
||
|
}
|
||
|
|
||
|
metric {
|
||
|
name = "cert_end_in"
|
||
|
tags = [ "${var.tcp_check_tags}" ]
|
||
|
type = "numeric"
|
||
|
unit = "seconds"
|
||
|
}
|
||
|
|
||
|
metric {
|
||
|
name = "tt_connect"
|
||
|
tags = [ "${var.tcp_check_tags}" ]
|
||
|
type = "numeric"
|
||
|
unit = "miliseconds"
|
||
|
}
|
||
|
|
||
|
tags = [ "${var.tcp_check_tags}" ]
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Out Parameters
|
||
|
|
||
|
* `check_by_collector` - Map of each check (value) that was created for every
|
||
|
specified broker (key).
|
||
|
|
||
|
## Import Example
|
||
|
|
||
|
`circonus_check` supports importing resources. Supposing the following
|
||
|
Terraform (and that the referenced [`circonus_metric`](metric.html) has already
|
||
|
been imported):
|
||
|
|
||
|
```
|
||
|
provider "circonus" {
|
||
|
alias = "b8fec159-f9e5-4fe6-ad2c-dc1ec6751586"
|
||
|
}
|
||
|
|
||
|
resource "circonus_metric" "used" {
|
||
|
name = "_usage`0`_used"
|
||
|
type = "numeric"
|
||
|
}
|
||
|
|
||
|
resource "circonus_check" "usage" {
|
||
|
collector {
|
||
|
id = "/broker/1"
|
||
|
}
|
||
|
|
||
|
json {
|
||
|
url = "https://api.circonus.com/account/current"
|
||
|
|
||
|
http_headers = {
|
||
|
"Accept" = "application/json"
|
||
|
"X-Circonus-App-Name" = "TerraformCheck"
|
||
|
"X-Circonus-Auth-Token" = "${var.api_token}"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
metric {
|
||
|
name = "${circonus_metric.used.name}"
|
||
|
type = "${circonus_metric.used.type}"
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
It is possible to import a `circonus_check` resource with the following command:
|
||
|
|
||
|
```
|
||
|
$ terraform import circonus_check.usage ID
|
||
|
```
|
||
|
|
||
|
Where `ID` is the `_cid` or Circonus ID of the Check Bundle
|
||
|
(e.g. `/check_bundle/12345`) and `circonus_check.usage` is the name of the
|
||
|
resource whose state will be populated as a result of the command.
|