terraform-provider-datadog

command module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2016 License: MPL-2.0 Imports: 2 Imported by: 0

README

Build status

terraform-provider-datadog

A Terraform plugin that provides resources for Datadog.

It currently supports 3 resources based on the Datadog monitor originally contributed by Vincenzo Prignano of Segmentio.

Feel free to open new issues for extra resources or bugs you find.

Want to contribute? Find a resource you want to add or work on an issue over here.

Download

Download builds for Darwin, Linux and Windows from the releases page. Pre-release is rebuild on each merge to master.

Resources

Service Checks

Example configuration:

resource "datadog_service_check" "bar" {
  name = "name for service check bar"
  message = "description for service check bar @pagerduty"
  check = "datadog.agent.up"
  check_count = 3
  tags = ["environment:foo", "host:bar"]
  keys = ["foo", "bar"]

  notify_no_data = false
}
Metric Alerts

Example configuration:

resource "datadog_metric_alert" "statsd_packet_count" {
    name        = "TF: stats_packet_count"
    message     = "statsd packet count {{host.hostname}}"
    metric      = "datadog.dogstatsd.packet.count"
    tags        = ["*"]
    keys        = ["host"]
    time_aggr   = "avg"
    time_window = "last_1h"
    operator    = ">"
    notify_no_data = 0
    space_aggr  = "sum"
    threshold = 2
    notify    = "@ojongerius@warning.com"
}
Outlier Alerts

Example configuration:

resource "datadog_outlier_alert" "foo" {
  name = "name for outlier_alert foo"
  message = "description for outlier_alert foo"

  algorithm = "mad"

  metric = "system.load.5"
  tags = ["environment:foo", "host:foo"]
  keys = ["host"]

  time_aggr = "avg"       // avg, sum, max, min, change, or pct_change
  time_window = "last_1h" // last_#m (5, 10, 15, 30), last_#h (1, 2, 4), or last_1d
  space_aggr = "avg"      // avg, sum, min, or max

  threshold = 3.0         // tolerance
  notify = "@hipchat-<name>"

  notify_no_data = false

}

Usage

Like any other Terraform interactions.

Tip: export DATADOG_API_KEY and DATADOG_APP_KEY as environment variables.

###Plan

ojongerius@hipster  ~/dev/go/datadog  terraform plan
Refreshing Terraform state prior to plan...


The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ datadog_metric_alert.statsd_packet_count
    keys.#:            "0" => "1"
    keys.0:            "" => "host"
    message:           "" => "statsd packet count {{host.hostname}}"
    metric:            "" => "datadog.dogstatsd.packet.count"
    name:              "" => "TF: stats_packet_count"
    notify:            "" => "@ojongerius@warning.com"
    notify_no_data:    "" => "0"
    operator:          "" => ">"
    renotify_interval: "" => "0"
    space_aggr:        "" => "sum"
    tags.#:            "0" => "1"
    tags.0:            "" => "*"
    threshold:         "" => "2"
    time_aggr:         "" => "avg"
    time_window:       "" => "last_1h"


Plan: 1 to add, 0 to change, 0 to destroy.

###Apply

ojongerius@hipster  ~/dev/go/datadog  terraform apply
datadog_metric_alert.statsd_packet_count: Creating...
  keys.#:            "0" => "1"
  keys.0:            "" => "host"
  message:           "" => "statsd packet count {{host.hostname}}"
  metric:            "" => "datadog.dogstatsd.packet.count"
  name:              "" => "TF: stats_packet_count"
  notify:            "" => "@ojongerius@warning.com"
  notify_no_data:    "" => "0"
  operator:          "" => ">"
  renotify_interval: "" => "0"
  space_aggr:        "" => "sum"
  tags.#:            "0" => "1"
  tags.0:            "" => "*"
  threshold:         "" => "2"
  time_aggr:         "" => "avg"
  time_window:       "" => "last_1h"
datadog_metric_alert.statsd_packet_count: Creation complete

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

Development

Running tests
Simple tests
> make test
go generate ./...
TF_ACC= go test ./...  -timeout=30s -parallel=4
?       github.com/ojongerius/terraform-provider-datadog[no test files]
ok      github.com/ojongerius/terraform-provider-datadog/datadog0.007s
go tool vet -asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc
-printf -rangeloops -shift -structtags -unsafeptr .
Acceptance tests

Much more extensive but need a valid Datadog API and APP key.

These tests will both create and destroy real resources.

ojongerius@hipster  ~/gocode/src/github.com/ojongerius/terraform-provider-datadog   KISS ●  make
testacc
go generate ./...
TF_ACC=1 go test ./datadog -v  -timeout 90m
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestAccDatadogMetricAlert_Basic
--- PASS: TestAccDatadogMetricAlert_Basic (3.65s)
=== RUN   TestAccDatadogOutlierAlert_Basic
--- PASS: TestAccDatadogOutlierAlert_Basic (2.46s)
=== RUN   TestAccDatadogServiceCheck_Basic
--- PASS: TestAccDatadogServiceCheck_Basic (2.49s)
PASS
ok      github.com/ojongerius/terraform-provider-datadog/datadog        8.614s
Building

Building defaults to the platform you run on, and depends on gox. If you do not have it installed:

go get github.com/mitchellh/gox
> make bin
 go generate ./...
 Compiling for OS: darwin and ARCH: amd64
 Number of parallel builds: 8

 -->    darwin/amd64: github.com/ojongerius/terraform-provider-datadog
 Looking for Terraform install

 Moving terraform-provider-datadog_darwin_amd64 to
 /Applications/terraform/terraform-provider-datadog

 Resulting binary:

 -rwxr-xr-x 1 ojongerius staff 10442740 4 Aug 18:32
 /Applications/terraform/terraform-provider-datadog

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL