Skip to content

Commit

Permalink
Add support for "require_full_window" and "locked".
Browse files Browse the repository at this point in the history
  • Loading branch information
ojongerius committed Apr 6, 2016
1 parent 84b913b commit 31e5cc8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions builtin/providers/datadog/resource_datadog_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ func resourceDatadogMonitor() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
},
"require_full_window": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
},
"locked": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
},
// TODO should actually be map[string]int
"silenced": &schema.Schema{
Type: schema.TypeMap,
Expand Down Expand Up @@ -159,6 +167,12 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor {
if attr, ok := d.GetOk("include_tags"); ok {
o.IncludeTags = attr.(bool)
}
if attr, ok := d.GetOk("require_full_window"); ok {
o.RequireFullWindow= attr.(bool)
}
if attr, ok := d.GetOk("locked"); ok {
o.Locked = attr.(bool)
}

m := datadog.Monitor{
Type: d.Get("type").(string),
Expand Down Expand Up @@ -233,6 +247,8 @@ func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error
d.Set("escalation_message", m.Options.EscalationMessage)
d.Set("silenced", m.Options.Silenced)
d.Set("include_tags", m.Options.IncludeTags)
d.Set("require_full_window", m.Options.RequireFullWindow)
d.Set("locked", m.Options.Locked)

return nil
}
Expand Down
12 changes: 12 additions & 0 deletions builtin/providers/datadog/resource_datadog_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func TestAccDatadogMonitor_Basic(t *testing.T) {
"datadog_monitor.foo", "thresholds.warning", "1"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "thresholds.critical", "2"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "require_full_window", "true"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "locked", "true"),
),
},
},
Expand Down Expand Up @@ -81,6 +85,10 @@ func TestAccDatadogMonitor_Updated(t *testing.T) {
"datadog_monitor.foo", "timeout_h", "60"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "include_tags", "true"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "require_full_window", "false"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "locked", "false"),
),
},
resource.TestStep{
Expand Down Expand Up @@ -195,6 +203,8 @@ resource "datadog_monitor" "foo" {
notify_audit = false
timeout_h = 60
include_tags = true
require_full_window = true
locked = true
}
`

Expand All @@ -219,6 +229,8 @@ resource "datadog_monitor" "foo" {
notify_audit = true
timeout_h = 70
include_tags = false
require_full_window = false
locked = false
silenced {
"*" = 0
}
Expand Down
3 changes: 3 additions & 0 deletions website/source/docs/providers/datadog/r/monitor.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ The following arguments are supported:
* `include_tags` (Optional) A boolean indicating whether notifications from this monitor will automatically insert its
triggering tags into the title. Defaults to true.
* `silenced` (Optional) Each scope will be muted until the given POSIX timestamp or forever if the value is 0.
* `require_full_window` (Optional) A boolean indicating whether a full window of data is required for evaluation.
It is highly recommend to set to false for sparse metrics, or some evaluations will be skipped.
* `locked` (Optional) A boolean indicating whether this monitor is locked.

To mute the alert completely:

Expand Down

0 comments on commit 31e5cc8

Please sign in to comment.