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

[datadogmonitor] Adding renotifyStatuses and indicating Locked is deprecated #1259

Merged
merged 8 commits into from
Jul 15, 2024
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: 5 additions & 1 deletion apis/datadoghq/v1alpha1/datadogmonitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package v1alpha1

import (
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -93,7 +94,8 @@ type DatadogMonitorOptions struct {
IncludeTags *bool `json:"includeTags,omitempty"`
// A Boolean indicating whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.
GroupbySimpleMonitor *bool `json:"groupbySimpleMonitor,omitempty"`
// Whether or not the monitor is locked (only editable by creator and admins).
// DEPRECATED: Whether or not the monitor is locked (only editable by creator and admins). Use `restricted_roles` instead.
// +deprecated
Locked *bool `json:"locked,omitempty"`
celenechang marked this conversation as resolved.
Show resolved Hide resolved
// 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.
Expand Down Expand Up @@ -125,6 +127,8 @@ type DatadogMonitorOptions struct {
RenotifyInterval *int64 `json:"renotifyInterval,omitempty"`
// The number of times re-notification messages should be sent on the current status at the provided re-notification interval.
RenotifyOccurrences *int64 `json:"renotifyOccurrences,omitempty"`
// The types of statuses for which re-notification messages should be sent. Valid values are alert, warn, no data.
RenotifyStatuses []datadogV1.MonitorRenotifyStatusType `json:"renotifyStatuses,omitempty"`
// A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly
// recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.
RequireFullWindow *bool `json:"requireFullWindow,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions apis/datadoghq/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion apis/datadoghq/v1alpha1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion config/crd/bases/v1/datadoghq.com_datadogmonitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
description: A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.
type: boolean
locked:
description: Whether or not the monitor is locked (only editable by creator and admins).
description: 'DEPRECATED: Whether or not the monitor is locked (only editable by creator and admins). Use `restricted_roles` instead.'
type: boolean
newGroupDelay:
description: |-
Expand Down Expand Up @@ -147,6 +147,12 @@ spec:
description: The number of times re-notification messages should be sent on the current status at the provided re-notification interval.
format: int64
type: integer
renotifyStatuses:
description: The types of statuses for which re-notification messages should be sent. Valid values are alert, warn, no data.
items:
description: MonitorRenotifyStatusType The different statuses for which renotification is supported.
type: string
type: array
requireFullWindow:
description: |-
A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly
Expand Down
4 changes: 4 additions & 0 deletions controllers/datadogmonitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func buildMonitor(logger logr.Logger, dm *datadoghqv1alpha1.DatadogMonitor) (*da
o.SetRenotifyOccurrences(*options.RenotifyOccurrences)
}

if options.RenotifyStatuses != nil {
o.SetRenotifyStatuses(options.RenotifyStatuses)
}

if options.TimeoutH != nil {
o.SetTimeoutH(*options.TimeoutH)
}
Expand Down
9 changes: 9 additions & 0 deletions controllers/datadogmonitor/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func Test_buildMonitor(t *testing.T) {
noDataTimeframe := int64(15)
renotifyInterval := int64(1440)
renotifyOccurrences := int64(1)
renotifyStatuses := []datadogV1.MonitorRenotifyStatusType{
datadogV1.MONITORRENOTIFYSTATUSTYPE_ALERT,
datadogV1.MONITORRENOTIFYSTATUSTYPE_WARN,
}

timeoutH := int64(2)
critThreshold := "0.05"
warnThreshold := "0.02"
Expand Down Expand Up @@ -71,6 +76,7 @@ func Test_buildMonitor(t *testing.T) {
OnMissingData: "default",
RenotifyOccurrences: &renotifyOccurrences,
RenotifyInterval: &renotifyInterval,
RenotifyStatuses: renotifyStatuses,
TimeoutH: &timeoutH,
Thresholds: &datadoghqv1alpha1.DatadogMonitorOptionsThresholds{
Critical: &critThreshold,
Expand Down Expand Up @@ -142,6 +148,9 @@ func Test_buildMonitor(t *testing.T) {
assert.Equal(t, *dm.Spec.Options.RenotifyOccurrences, monitor.Options.GetRenotifyOccurrences(), "discrepancy found in parameter: RenotifyOccurrences")
assert.Equal(t, *dm.Spec.Options.RenotifyOccurrences, monitorUR.Options.GetRenotifyOccurrences(), "discrepancy found in parameter: RenotifyOccurrences")

assert.Equal(t, dm.Spec.Options.RenotifyStatuses, monitor.Options.GetRenotifyStatuses(), "discrepancy found in parameter: RenotifyStatuses")
assert.Equal(t, dm.Spec.Options.RenotifyStatuses, monitorUR.Options.GetRenotifyStatuses(), "discrepancy found in parameter: RenotifyStatuses")

assert.Equal(t, *dm.Spec.Options.TimeoutH, monitor.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH")
assert.Equal(t, *dm.Spec.Options.TimeoutH, monitorUR.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH")

Expand Down
Loading