github.com/sixgill/terraform@v0.9.0-beta2.0.20170316214032-033f6226ae50/website/source/docs/providers/circonus/r/check.html.markdown (about) 1 --- 2 layout: "circonus" 3 page_title: "Circonus: circonus_check" 4 sidebar_current: "docs-circonus-resource-circonus_check" 5 description: |- 6 Manages a Circonus check. 7 --- 8 9 # circonus\_check 10 11 The ``circonus_check`` resource creates and manages a 12 [Circonus Check](https://login.circonus.com/resources/api/calls/check_bundle). 13 14 ~> **NOTE regarding `cirocnus_check` vs a Circonus Check Bundle:** The 15 `circonus_check` resource is implemented in terms of a 16 [Circonus Check Bundle](https://login.circonus.com/resources/api/calls/check_bundle). 17 The `circonus_check` creates a higher-level abstraction over the implementation 18 of a Check Bundle. As such, the naming and structure does not map 1:1 with the 19 underlying Circonus API. 20 21 ## Usage 22 23 ``` 24 variable api_token { 25 default = "my-token" 26 } 27 28 resource "circonus_check" "usage" { 29 name = "Circonus Usage Check" 30 31 notes = <<-EOF 32 A check to extract a usage metric. 33 EOF 34 35 collector { 36 id = "/broker/1" 37 } 38 39 metric { 40 name = "${circonus_metric.used.name}" 41 tags = "${circonus_metric.used.tags}" 42 type = "${circonus_metric.used.type}" 43 unit = "${circonus_metric.used.unit}" 44 } 45 46 json { 47 url = "https://api.circonus.com/v2" 48 49 http_headers = { 50 Accept = "application/json" 51 X-Circonus-App-Name = "TerraformCheck" 52 X-Circonus-Auth-Token = "${var.api_token}" 53 } 54 } 55 56 period = 60 57 tags = ["source:circonus", "author:terraform"] 58 timeout = 10 59 } 60 61 resource "circonus_metric" "used" { 62 name = "_usage`0`_used" 63 type = "numeric" 64 unit = "qty" 65 66 tags = { 67 source = "circonus" 68 } 69 } 70 ``` 71 72 ## Argument Reference 73 74 * `active` - (Optional) Whether or not the check is enabled or not (default 75 `true`). 76 77 * `caql` - (Optional) A [Circonus Analytics Query Language 78 (CAQL)](https://login.circonus.com/user/docs/CAQL) check. See below for 79 details on how to configure a `caql` check. 80 81 * `cloudwatch` - (Optional) A [CloudWatch 82 check](https://login.circonus.com/user/docs/Data/CheckTypes/CloudWatch) check. 83 See below for details on how to configure a `cloudwatch` check. 84 85 * `collector` - (Required) A collector ID. The collector(s) that are 86 responsible for running a `circonus_check`. The `id` can be the Circonus ID 87 for a Circonus collector (a.k.a. "broker") running in the cloud or an 88 enterprise collector running in your datacenter. One collection of metrics 89 will be automatically created for each `collector` specified. 90 91 * `http` - (Optional) A poll-based HTTP check. See below for details on how to configure 92 the `http` check. 93 94 * `httptrap` - (Optional) An push-based HTTP check. This check method expects 95 clients to send a specially crafted HTTP JSON payload. See below for details 96 on how to configure the `httptrap` check. 97 98 * `icmp_ping` - (Optional) An ICMP ping check. See below for details on how to 99 configure the `icmp_ping` check. 100 101 * `json` - (Optional) A JSON check. See below for details on how to configure 102 the `json` check. 103 104 * `metric_limit` - (Optional) Setting a metric limit will tell the Circonus 105 backend to periodically look at the check to see if there are additional 106 metrics the collector has seen that we should collect. It will not reactivate 107 metrics previously collected and then marked as inactive. Values are `0` to 108 disable, `-1` to enable all metrics or `N+` to collect up to the value `N` 109 (both `-1` and `N+` can not exceed other account restrictions). 110 111 * `mysql` - (Optional) A MySQL check. See below for details on how to configure 112 the `mysql` check. 113 114 * `name` - (Optional) The name of the check that will be displayed in the web 115 interface. 116 117 * `notes` - (Optional) Notes about this check. 118 119 * `period` - (Optional) The period between each time the check is made in 120 seconds. 121 122 * `postgresql` - (Optional) A PostgreSQL check. See below for details on how to 123 configure the `postgresql` check. 124 125 * `metric` - (Required) A list of one or more `metric` configurations. All 126 metrics obtained from this check instance will be available as individual 127 metric streams. See below for a list of supported `metric` attrbutes. 128 129 * `tags` - (Optional) A list of tags assigned to this check. 130 131 * `target` - (Required) A string containing the location of the thing being 132 checked. This value changes based on the check type. For example, for an 133 `http` check type this would be the URL you're checking. For a DNS check it 134 would be the hostname you wanted to look up. 135 136 * `tcp` - (Optional) A TCP check. See below for details on how to configure the 137 `tcp` check (includes TLS support). 138 139 * `timeout` - (Optional) A floating point number representing the maximum number 140 of seconds this check should wait for a result. Defaults to `10.0`. 141 142 ## Supported `metric` Attributes 143 144 The following attributes are available within a `metric`. 145 146 * `active` - (Optional) Whether or not the metric is active or not. Defaults to `true`. 147 * `name` - (Optional) The name of the metric. A string containing freeform text. 148 * `tags` - (Optional) A list of tags assigned to the metric. 149 * `type` - (Required) A string containing either `numeric`, `text`, `histogram`, `composite`, or `caql`. 150 * `units` - (Optional) The unit of measurement the metric represents (e.g., bytes, seconds, milliseconds). A string containing freeform text. 151 152 ## Supported Check Types 153 154 Circonus supports a variety of different checks. Each check type has its own 155 set of options that must be configured. Each check type conflicts with every 156 other check type (i.e. a `circonus_check` configured for a `json` check will 157 conflict with all other check types, therefore a `postgresql` check must be a 158 different `circonus_check` resource). 159 160 ### `caql` Check Type Attributes 161 162 * `query` - (Required) The [CAQL 163 Query](https://login.circonus.com/user/docs/caql_reference) to run. 164 165 Available metrics depend on the payload returned in the `caql` check. See the 166 [`caql` check type](https://login.circonus.com/resources/api/calls/check_bundle) for 167 additional details. 168 169 ### `cloudwatch` Check Type Attributes 170 171 * `api_key` - (Required) The AWS access key. If this value is not explicitly 172 set, this value is populated by the environment variable `AWS_ACCESS_KEY_ID`. 173 174 * `api_secret` - (Required) The AWS secret key. If this value is not explicitly 175 set, this value is populated by the environment variable `AWS_SECRET_ACCESS_KEY`. 176 177 * `dimmensions` - (Required) A map of the CloudWatch dimmensions to include in 178 the check. 179 180 * `metric` - (Required) A list of metric names to collect in this check. 181 182 * `namespace` - (Required) The namespace to pull parameters from. 183 184 * `url` - (Required) The AWS URL to pull from. This should be set to the 185 region-specific endpoint (e.g. prefer 186 `https://monitoring.us-east-1.amazonaws.com` over 187 `https://monitoring.amazonaws.com`). 188 189 * `version` - (Optional) The version of the Cloudwatch API to use. Defaults to 190 `2010-08-01`. 191 192 Available metrics depend on the payload returned in the `cloudwatch` check. See the 193 [`cloudwatch` check type](https://login.circonus.com/resources/api/calls/check_bundle) for 194 additional details. The `circonus_check` `period` attribute must be set to 195 either `60s` or `300s` for CloudWatch metrics. 196 197 Example CloudWatch check (partial metrics collection): 198 199 ``` 200 variable "cloudwatch_rds_tags" { 201 type = "list" 202 default = [ 203 "app:postgresql", 204 "app:rds", 205 "source:cloudwatch", 206 ] 207 } 208 209 resource "circonus_check" "rds_metrics" { 210 active = true 211 name = "Terraform test: RDS Metrics via CloudWatch" 212 notes = "Collect RDS metrics" 213 period = "60s" 214 215 collector { 216 id = "/broker/1" 217 } 218 219 cloudwatch { 220 dimmensions = { 221 DBInstanceIdentifier = "my-db-name", 222 } 223 224 metric = [ 225 "CPUUtilization", 226 "DatabaseConnections", 227 ] 228 229 namespace = "AWS/RDS" 230 url = "https://monitoring.us-east-1.amazonaws.com" 231 } 232 233 metric { 234 name = "CPUUtilization" 235 tags = [ "${var.cloudwatch_rds_tags}" ] 236 type = "numeric" 237 unit = "%" 238 } 239 240 metric { 241 name = "DatabaseConnections" 242 tags = [ "${var.cloudwatch_rds_tags}" ] 243 type = "numeric" 244 unit = "connections" 245 } 246 } 247 ``` 248 249 ### `http` Check Type Attributes 250 251 * `auth_method` - (Optional) HTTP Authentication method to use. When set must 252 be one of the values `Basic`, `Digest`, or `Auto`. 253 254 * `auth_password` - (Optional) The password to use during authentication. 255 256 * `auth_user` - (Optional) The user to authenticate as. 257 258 * `body_regexp` - (Optional) This regular expression is matched against the body 259 of the response. If a match is not found, the check will be marked as "bad." 260 261 * `ca_chain` - (Optional) A path to a file containing all the certificate 262 authorities that should be loaded to validate the remote certificate (for TLS 263 checks). 264 265 * `certificate_file` - (Optional) A path to a file containing the client 266 certificate that will be presented to the remote server (for TLS checks). 267 268 * `ciphers` - (Optional) A list of ciphers to be used in the TLS protocol (for 269 HTTPS checks). 270 271 * `code` - (Optional) The HTTP code that is expected. If the code received does 272 not match this regular expression, the check is marked as "bad." 273 274 * `extract` - (Optional) This regular expression is matched against the body of 275 the response globally. The first capturing match is the key and the second 276 capturing match is the value. Each key/value extracted is registered as a 277 metric for the check. 278 279 * `headers` - (Optional) A map of the HTTP headers to be sent when executing the 280 check. 281 282 * `key_file` - (Optional) A path to a file containing key to be used in 283 conjunction with the cilent certificate (for TLS checks). 284 285 * `method` - (Optional) The HTTP Method to use. Defaults to `GET`. 286 287 * `payload` - (Optional) The information transferred as the payload of an HTTP 288 request. 289 290 * `read_limit` - (Optional) Sets an approximate limit on the data read (`0` 291 means no limit). Default `0`. 292 293 * `redirects` - (Optional) The maximum number of HTTP `Location` header 294 redirects to follow. Default `0`. 295 296 * `url` - (Required) The target for this `json` check. The `url` must include 297 the scheme, host, port (optional), and path to use 298 (e.g. `https://app1.example.org/healthz`) 299 300 * `version` - (Optional) The HTTP version to use. Defaults to `1.1`. 301 302 Available metrics include: `body_match`, `bytes`, `cert_end`, `cert_end_in`, 303 `cert_error`, `cert_issuer`, `cert_start`, `cert_subject`, `code`, `duration`, 304 `truncated`, `tt_connect`, and `tt_firstbyte`. See the 305 [`http` check type](https://login.circonus.com/resources/api/calls/check_bundle) for 306 additional details. 307 308 ### `httptrap` Check Type Attributes 309 310 * `async_metrics` - (Optional) Boolean value specifies whether or not httptrap 311 metrics are logged immediately or held until the status message is to be 312 emitted. Default `false`. 313 314 * `secret` - (Optional) Specify the secret with which metrics may be 315 submitted. 316 317 Available metrics depend on the payload returned in the `httptrap` doc. See 318 the [`httptrap` check type](https://login.circonus.com/resources/api/calls/check_bundle) 319 for additional details. 320 321 ### `json` Check Type Attributes 322 323 * `auth_method` - (Optional) HTTP Authentication method to use. When set must 324 be one of the values `Basic`, `Digest`, or `Auto`. 325 326 * `auth_password` - (Optional) The password to use during authentication. 327 328 * `auth_user` - (Optional) The user to authenticate as. 329 330 * `ca_chain` - (Optional) A path to a file containing all the certificate 331 authorities that should be loaded to validate the remote certificate (for TLS 332 checks). 333 334 * `certificate_file` - (Optional) A path to a file containing the client 335 certificate that will be presented to the remote server (for TLS checks). 336 337 * `ciphers` - (Optional) A list of ciphers to be used in the TLS protocol (for 338 HTTPS checks). 339 340 * `headers` - (Optional) A map of the HTTP headers to be sent when executing the 341 check. 342 343 * `key_file` - (Optional) A path to a file containing key to be used in 344 conjunction with the cilent certificate (for TLS checks). 345 346 * `method` - (Optional) The HTTP Method to use. Defaults to `GET`. 347 348 * `port` - (Optional) The TCP Port number to use. Defaults to `81`. 349 350 * `read_limit` - (Optional) Sets an approximate limit on the data read (`0` 351 means no limit). Default `0`. 352 353 * `redirects` - (Optional) The maximum number of HTTP `Location` header 354 redirects to follow. Default `0`. 355 356 * `url` - (Required) The target for this `json` check. The `url` must include 357 the scheme, host, port (optional), and path to use 358 (e.g. `https://app1.example.org/healthz`) 359 360 * `version` - (Optional) The HTTP version to use. Defaults to `1.1`. 361 362 Available metrics depend on the payload returned in the `json` doc. See the 363 [`json` check type](https://login.circonus.com/resources/api/calls/check_bundle) for 364 additional details. 365 366 ### `icmp_ping` Check Type Attributes 367 368 The `icmp_ping` check requires the `target` top-level attribute to be set. 369 370 * `availability` - (Optional) The percentage of ping packets that must be 371 returned for this measurement to be considered successful. Defaults to 372 `100.0`. 373 * `count` - (Optional) The number of ICMP ping packets to send. Defaults to 374 `5`. 375 * `interval` - (Optional) Interval between packets. Defaults to `2s`. 376 377 Available metrics include: `available`, `average`, `count`, `maximum`, and 378 `minimum`. See the 379 [`ping_icmp` check type](https://login.circonus.com/resources/api/calls/check_bundle) 380 for additional details. 381 382 ### `mysql` Check Type Attributes 383 384 The `mysql` check requires the `target` top-level attribute to be set. 385 386 * `dsn` - (Required) The [MySQL DSN/connect 387 string](https://github.com/go-sql-driver/mysql/blob/master/README.md) to 388 use to talk to MySQL. 389 * `query` - (Required) The SQL query to execute. 390 391 ### `postgresql` Check Type Attributes 392 393 The `postgresql` check requires the `target` top-level attribute to be set. 394 395 * `dsn` - (Required) The [PostgreSQL DSN/connect 396 string](https://www.postgresql.org/docs/current/static/libpq-connect.html) to 397 use to talk to PostgreSQL. 398 * `query` - (Required) The SQL query to execute. 399 400 Available metric names are dependent on the output of the `query` being run. 401 402 ### `tcp` Check Type Attributes 403 404 * `banner_regexp` - (Optional) This regular expression is matched against the 405 response banner. If a match is not found, the check will be marked as bad. 406 407 * `ca_chain` - (Optional) A path to a file containing all the certificate 408 authorities that should be loaded to validate the remote certificate (for TLS 409 checks). 410 411 * `certificate_file` - (Optional) A path to a file containing the client 412 certificate that will be presented to the remote server (for TLS checks). 413 414 * `ciphers` - (Optional) A list of ciphers to be used in the TLS protocol (for 415 HTTPS checks). 416 417 * `host` - (Required) Hostname or IP address of the host to connect to. 418 419 * `key_file` - (Optional) A path to a file containing key to be used in 420 conjunction with the cilent certificate (for TLS checks). 421 422 * `port` - (Required) Integer specifying the port on which the management 423 interface can be reached. 424 425 * `tls` - (Optional) When enabled establish a TLS connection. 426 427 Available metrics include: `banner`, `banner_match`, `cert_end`, `cert_end_in`, 428 `cert_error`, `cert_issuer`, `cert_start`, `cert_subject`, `duration`, 429 `tt_connect`, `tt_firstbyte`. See the 430 [`tcp` check type](https://login.circonus.com/resources/api/calls/check_bundle) 431 for additional details. 432 433 Sample `tcp` check: 434 435 ``` 436 resource "circonus_check" "tcp_check" { 437 name = "TCP and TLS check" 438 notes = "Obtains the connect time and TTL for the TLS cert" 439 period = "60s" 440 441 collector { 442 id = "/broker/1" 443 } 444 445 tcp { 446 host = "127.0.0.1" 447 port = 443 448 tls = true 449 } 450 451 metric { 452 name = "cert_end_in" 453 tags = [ "${var.tcp_check_tags}" ] 454 type = "numeric" 455 unit = "seconds" 456 } 457 458 metric { 459 name = "tt_connect" 460 tags = [ "${var.tcp_check_tags}" ] 461 type = "numeric" 462 unit = "miliseconds" 463 } 464 465 tags = [ "${var.tcp_check_tags}" ] 466 } 467 ``` 468 469 ## Out Parameters 470 471 * `check_by_collector` - Map of each check (value) that was created for every 472 specified broker (key). 473 474 ## Import Example 475 476 `circonus_check` supports importing resources. Supposing the following 477 Terraform (and that the referenced [`circonus_metric`](metric.html) has already 478 been imported): 479 480 ``` 481 provider "circonus" { 482 alias = "b8fec159-f9e5-4fe6-ad2c-dc1ec6751586" 483 } 484 485 resource "circonus_metric" "used" { 486 name = "_usage`0`_used" 487 type = "numeric" 488 } 489 490 resource "circonus_check" "usage" { 491 collector { 492 id = "/broker/1" 493 } 494 495 json { 496 url = "https://api.circonus.com/account/current" 497 498 http_headers = { 499 "Accept" = "application/json" 500 "X-Circonus-App-Name" = "TerraformCheck" 501 "X-Circonus-Auth-Token" = "${var.api_token}" 502 } 503 } 504 505 metric { 506 name = "${circonus_metric.used.name}" 507 type = "${circonus_metric.used.type}" 508 } 509 } 510 ``` 511 512 It is possible to import a `circonus_check` resource with the following command: 513 514 ``` 515 $ terraform import circonus_check.usage ID 516 ``` 517 518 Where `ID` is the `_cid` or Circonus ID of the Check Bundle 519 (e.g. `/check_bundle/12345`) and `circonus_check.usage` is the name of the 520 resource whose state will be populated as a result of the command.