From 7e4a8c8781272f37ba31bc4375b7a648c322690c Mon Sep 17 00:00:00 2001 From: lexicalunit Date: Fri, 15 Nov 2024 09:58:41 -0800 Subject: [PATCH 1/3] Change enable_samples to optional --- datadog/resource_datadog_monitor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datadog/resource_datadog_monitor.go b/datadog/resource_datadog_monitor.go index b37ed7671..a5d338929 100644 --- a/datadog/resource_datadog_monitor.go +++ b/datadog/resource_datadog_monitor.go @@ -332,7 +332,7 @@ func resourceDatadogMonitor() *schema.Resource { "enable_samples": { Description: "Whether or not a list of samples which triggered the alert is included. This is only used by CI Test and Pipeline monitors.", Type: schema.TypeBool, - Computed: true, + Optional: true, }, "force_delete": { Description: "A boolean indicating whether this monitor can be deleted even if it’s referenced by other resources (e.g. SLO, composite monitor).", From 559bc3a27475362bf98ae494de0298df9ea3c4cf Mon Sep 17 00:00:00 2001 From: Kevin Zou Date: Mon, 16 Dec 2024 15:06:23 -0500 Subject: [PATCH 2/3] update docs --- docs/resources/monitor.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/monitor.md b/docs/resources/monitor.md index e54f96b17..73132f214 100644 --- a/docs/resources/monitor.md +++ b/docs/resources/monitor.md @@ -49,6 +49,7 @@ Email notifications can be sent to specific users by using the same `@username` ### Optional - `enable_logs_sample` (Boolean) A boolean indicating whether or not to include a list of log values which triggered the alert. This is only used by log monitors. Defaults to `false`. +- `enable_samples` (Boolean) Whether or not a list of samples which triggered the alert is included. This is only used by CI Test and Pipeline monitors. - `escalation_message` (String) A message to include with a re-notification. Supports the `@username` notification allowed elsewhere. - `evaluation_delay` (Number) (Only applies to metric alert) Time (in seconds) to delay evaluation, as a non-negative integer. @@ -86,7 +87,6 @@ We recommend at least 2x the monitor timeframe for metric alerts or 2 minutes fo ### Read-Only -- `enable_samples` (Boolean) Whether or not a list of samples which triggered the alert is included. This is only used by CI Test and Pipeline monitors. - `id` (String) The ID of this resource. From 6d83dff2fa5a47824e3d604eb748de7342730dd0 Mon Sep 17 00:00:00 2001 From: Kevin Zou Date: Tue, 17 Dec 2024 11:31:56 -0500 Subject: [PATCH 3/3] properly update the state --- datadog/resource_datadog_monitor.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/datadog/resource_datadog_monitor.go b/datadog/resource_datadog_monitor.go index a5d338929..1d216e573 100644 --- a/datadog/resource_datadog_monitor.go +++ b/datadog/resource_datadog_monitor.go @@ -1088,6 +1088,12 @@ func updateMonitorState(d *schema.ResourceData, meta interface{}, m *datadogV1.M } } + if m.GetType() == datadogV1.MONITORTYPE_CI_PIPELINES_ALERT || m.GetType() == datadogV1.MONITORTYPE_CI_TESTS_ALERT { + if err := d.Set("enable_samples", m.Options.GetEnableSamples()); err != nil { + return diag.FromErr(err) + } + } + if err := d.Set("notify_by", m.Options.GetNotifyBy()); err != nil { return diag.FromErr(err) }