diff --git a/builtin/providers/datadog/resource_datadog_monitor.go b/builtin/providers/datadog/resource_datadog_monitor.go index 4d4d25d2c..4aeb0d637 100644 --- a/builtin/providers/datadog/resource_datadog_monitor.go +++ b/builtin/providers/datadog/resource_datadog_monitor.go @@ -85,6 +85,11 @@ func resourceDatadogMonitor() *schema.Resource { Computed: true, Optional: true, }, + "evaluation_delay": { + Type: schema.TypeInt, + Computed: true, + Optional: true, + }, "no_data_timeframe": { Type: schema.TypeInt, Optional: true, @@ -163,6 +168,9 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor { if attr, ok := d.GetOk("new_host_delay"); ok { o.SetNewHostDelay(attr.(int)) } + if attr, ok := d.GetOk("evaluation_delay"); ok { + o.SetNewHostDelay(attr.(int)) + } if attr, ok := d.GetOk("no_data_timeframe"); ok { o.NoDataTimeframe = datadog.NoDataTimeframe(attr.(int)) } @@ -274,6 +282,7 @@ func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error d.Set("thresholds", thresholds) d.Set("new_host_delay", m.Options.GetNewHostDelay()) + d.Set("evaluation_delay", m.Options.GetNewHostDelay()) d.Set("notify_no_data", m.Options.GetNotifyNoData()) d.Set("no_data_timeframe", m.Options.NoDataTimeframe) d.Set("renotify_interval", m.Options.GetRenotifyInterval()) @@ -340,6 +349,9 @@ func resourceDatadogMonitorUpdate(d *schema.ResourceData, meta interface{}) erro if attr, ok := d.GetOk("new_host_delay"); ok { o.SetNewHostDelay(attr.(int)) } + if attr, ok := d.GetOk("evaluation_delay"); ok { + o.SetNewHostDelay(attr.(int)) + } if attr, ok := d.GetOk("no_data_timeframe"); ok { o.NoDataTimeframe = datadog.NoDataTimeframe(attr.(int)) } diff --git a/builtin/providers/datadog/resource_datadog_monitor_test.go b/builtin/providers/datadog/resource_datadog_monitor_test.go index 41791455e..f2cce05fb 100644 --- a/builtin/providers/datadog/resource_datadog_monitor_test.go +++ b/builtin/providers/datadog/resource_datadog_monitor_test.go @@ -33,6 +33,8 @@ func TestAccDatadogMonitor_Basic(t *testing.T) { "datadog_monitor.foo", "notify_no_data", "false"), resource.TestCheckResourceAttr( "datadog_monitor.foo", "new_host_delay", "600"), + resource.TestCheckResourceAttr( + "datadog_monitor.foo", "evaluation_delay", "600"), resource.TestCheckResourceAttr( "datadog_monitor.foo", "renotify_interval", "60"), resource.TestCheckResourceAttr( @@ -113,6 +115,8 @@ func TestAccDatadogMonitor_Updated(t *testing.T) { "datadog_monitor.foo", "notify_no_data", "false"), resource.TestCheckResourceAttr( "datadog_monitor.foo", "new_host_delay", "600"), + resource.TestCheckResourceAttr( + "datadog_monitor.foo", "evaluation_delay", "600"), resource.TestCheckResourceAttr( "datadog_monitor.foo", "renotify_interval", "60"), resource.TestCheckResourceAttr( @@ -153,6 +157,8 @@ func TestAccDatadogMonitor_Updated(t *testing.T) { "datadog_monitor.foo", "notify_no_data", "true"), resource.TestCheckResourceAttr( "datadog_monitor.foo", "new_host_delay", "900"), + resource.TestCheckResourceAttr( + "datadog_monitor.foo", "evaluation_delay", "900"), resource.TestCheckResourceAttr( "datadog_monitor.foo", "no_data_timeframe", "20"), resource.TestCheckResourceAttr( @@ -288,6 +294,7 @@ resource "datadog_monitor" "foo" { notify_audit = false timeout_h = 60 new_host_delay = 600 + evaluation_delay = 600 include_tags = true require_full_window = true locked = false @@ -386,6 +393,7 @@ resource "datadog_monitor" "foo" { notify_no_data = true new_host_delay = 900 + evaluation_delay = 900 no_data_timeframe = 20 renotify_interval = 40 escalation_message = "the situation has escalated! @pagerduty" diff --git a/website/source/docs/providers/datadog/r/monitor.html.markdown b/website/source/docs/providers/datadog/r/monitor.html.markdown index 977b50a48..ec1ab8b1d 100644 --- a/website/source/docs/providers/datadog/r/monitor.html.markdown +++ b/website/source/docs/providers/datadog/r/monitor.html.markdown @@ -85,6 +85,10 @@ The following arguments are supported: * `new_host_delay` (Optional) Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non negative integer. Defaults to 300. +* `evaluation_delay` (Optional) Time (in seconds) to delay evaluation, as a non-negative integer. + For example, if the value is set to 300 (5min), the timeframe is set to last_5m and the time is 7:00, + the monitor will evaluate data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled + metrics to ensure the monitor will always have data during evaluation. * `no_data_timeframe` (Optional) The number of minutes before a monitor will notify when data stops reporting. Must be at least 2x the monitor timeframe for metric alerts or 2 minutes for service checks. Default: 2x timeframe for metric alerts, 2 minutes for service checks.