Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for groupby_simple_monitor option to monitor resource #952

Merged
merged 9 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions datadog/data_source_datadog_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ func dataSourceDatadogMonitor() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"groupby_simple_monitor": {
Description: "Whether or not to trigger one alert if any source breaches a threshold.",
Type: schema.TypeBool,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -328,6 +333,7 @@ func dataSourceDatadogMonitorsRead(d *schema.ResourceData, meta interface{}) err
d.Set("tags", tags)
d.Set("require_full_window", m.Options.GetRequireFullWindow()) // TODO Is this one of those options that we neeed to check?
d.Set("locked", m.Options.GetLocked())
d.Set("groupby_simple_monitor", m.Options.GetGroupbySimpleMonitor())

if m.GetType() == datadogV1.MONITORTYPE_LOG_ALERT {
d.Set("enable_logs_sample", m.Options.GetEnableLogsSample())
Expand Down
12 changes: 12 additions & 0 deletions datadog/resource_datadog_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ func resourceDatadogMonitor() *schema.Resource {
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"groupby_simple_monitor": {
Description: "Whether or not to trigger one alert if any source breaches a threshold. This is only used by log monitors. Defaults to `false`.",
Type: schema.TypeBool,
Optional: true,
},
// since this is only useful for "log alert" type, we don't set a default value
// if we did set it, it would be used for all types; we have to handle this manually
// throughout the code
Expand Down Expand Up @@ -459,6 +464,10 @@ func buildMonitorStruct(d builtResource) (*datadogV1.Monitor, *datadogV1.Monitor
} else {
o.SetEnableLogsSample(false)
}

if attr, ok := d.GetOk("groupby_simple_monitor"); ok {
o.SetGroupbySimpleMonitor(attr.(bool))
}
}

m := datadogV1.NewMonitor()
Expand Down Expand Up @@ -685,6 +694,9 @@ func updateMonitorState(d *schema.ResourceData, meta interface{}, m *datadogV1.M
if err := d.Set("enable_logs_sample", m.Options.GetEnableLogsSample()); err != nil {
return err
}
if err := d.Set("groupby_simple_monitor", m.Options.GetGroupbySimpleMonitor()); err != nil {
return err
}
}

// The Datadog API doesn't return old timestamps or support a special value for unmuting scopes
Expand Down
2 changes: 1 addition & 1 deletion datadog/tests/cassettes/TestAccDatadogMonitor_Log.freeze
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2020-12-31T15:44:37.591066+01:00
2021-03-02T14:57:26.387907+01:00
Loading