parent
c2041b7488
commit
5a4578edf6
|
@ -56,7 +56,7 @@ func resourceDatadogMonitor() *schema.Resource {
|
||||||
// Options
|
// Options
|
||||||
"thresholds": &schema.Schema{
|
"thresholds": &schema.Schema{
|
||||||
Type: schema.TypeMap,
|
Type: schema.TypeMap,
|
||||||
Required: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"ok": &schema.Schema{
|
"ok": &schema.Schema{
|
||||||
|
@ -69,7 +69,7 @@ func resourceDatadogMonitor() *schema.Resource {
|
||||||
},
|
},
|
||||||
"critical": &schema.Schema{
|
"critical": &schema.Schema{
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Required: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -51,6 +51,42 @@ func TestAccDatadogMonitor_Basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccDatadogMonitor_BasicNoTreshold(t *testing.T) {
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckDatadogMonitorDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccCheckDatadogMonitorConfigNoThresholds,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckDatadogMonitorExists("datadog_monitor.foo"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "name", "name for monitor foo"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "message", "some message Notify: @hipchat-channel"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "type", "metric alert"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "query", "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "notify_no_data", "false"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "renotify_interval", "60"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "require_full_window", "true"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "locked", "false"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "tags.foo", "bar"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"datadog_monitor.foo", "tags.bar", "baz"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestAccDatadogMonitor_Updated(t *testing.T) {
|
func TestAccDatadogMonitor_Updated(t *testing.T) {
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -255,6 +291,29 @@ resource "datadog_monitor" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
const testAccCheckDatadogMonitorConfigNoThresholds = `
|
||||||
|
resource "datadog_monitor" "foo" {
|
||||||
|
name = "name for monitor foo"
|
||||||
|
type = "metric alert"
|
||||||
|
message = "some message Notify: @hipchat-channel"
|
||||||
|
escalation_message = "the situation has escalated @pagerduty"
|
||||||
|
|
||||||
|
query = "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2"
|
||||||
|
|
||||||
|
notify_no_data = false
|
||||||
|
renotify_interval = 60
|
||||||
|
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 60
|
||||||
|
include_tags = true
|
||||||
|
require_full_window = true
|
||||||
|
locked = false
|
||||||
|
tags {
|
||||||
|
"foo" = "bar"
|
||||||
|
"bar" = "baz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
const testAccCheckDatadogMonitorConfig_ints = `
|
const testAccCheckDatadogMonitorConfig_ints = `
|
||||||
resource "datadog_monitor" "foo" {
|
resource "datadog_monitor" "foo" {
|
||||||
|
|
|
@ -60,10 +60,27 @@ The following arguments are supported:
|
||||||
Email notifications can be sent to specific users by using the same '@username' notation as events.
|
Email notifications can be sent to specific users by using the same '@username' notation as events.
|
||||||
* `escalation_message` - (Optional) A message to include with a re-notification. Supports the '@username'
|
* `escalation_message` - (Optional) A message to include with a re-notification. Supports the '@username'
|
||||||
notification allowed elsewhere.
|
notification allowed elsewhere.
|
||||||
* `thresholds` - (Required) Thresholds by threshold type:
|
* `thresholds` - (Optional)
|
||||||
* `ok`
|
* Metric alerts:
|
||||||
* `warning`
|
A dictionary of thresholds by threshold type. Currently we have two threshold types for metric alerts: critical and warning. Critical is defined in the query, but can also be specified in this option. Warning threshold can only be specified using the thresholds option.
|
||||||
* `critical`
|
Example usage:
|
||||||
|
```
|
||||||
|
thresholds {
|
||||||
|
critical = 90
|
||||||
|
warning = 80
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* Service checks:
|
||||||
|
A dictionary of thresholds by status. Because service checks can have multiple thresholds, we don't define them directly in the query.
|
||||||
|
Default values:
|
||||||
|
```
|
||||||
|
thresholds {
|
||||||
|
ok = 1
|
||||||
|
critical = 1
|
||||||
|
warning = 1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
* `notify_no_data` (Optional) A boolean indicating whether this monitor will notify when data stops reporting. Defaults
|
* `notify_no_data` (Optional) A boolean indicating whether this monitor will notify when data stops reporting. Defaults
|
||||||
to true.
|
to true.
|
||||||
* `no_data_timeframe` (Optional) The number of minutes before a monitor will notify when data stops reporting. Must be at
|
* `no_data_timeframe` (Optional) The number of minutes before a monitor will notify when data stops reporting. Must be at
|
||||||
|
|
Loading…
Reference in New Issue