diff --git a/Makefile b/Makefile index 27e28e2d1..d4a9223a0 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ $(KUSTOMIZE): Makefile ## Download kustomize locally if necessary. ENVTEST = bin/$(PLATFORM)/setup-envtest $(ENVTEST): Makefile ## Download envtest-setup locally if necessary. - $(call go-get-tool,$@,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) + $(call go-get-tool,$@,sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240320141353-395cfc7486e6) # go-get-tool will 'go get' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/apis/datadoghq/v1alpha1/datadogmonitor_types.go b/apis/datadoghq/v1alpha1/datadogmonitor_types.go index ddefceef9..af5b36c9c 100644 --- a/apis/datadoghq/v1alpha1/datadogmonitor_types.go +++ b/apis/datadoghq/v1alpha1/datadogmonitor_types.go @@ -91,6 +91,8 @@ type DatadogMonitorOptions struct { EvaluationDelay *int64 `json:"evaluationDelay,omitempty"` // A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title. 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). Locked *bool `json:"locked,omitempty"` // Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of @@ -104,6 +106,12 @@ type DatadogMonitorOptions struct { NotificationPresetName DatadogMonitorOptionsNotificationPreset `json:"notificationPresetName,omitempty"` // A Boolean indicating whether tagged users are notified on changes to this monitor. NotifyAudit *bool `json:"notifyAudit,omitempty"` + // A string indicating the granularity a monitor alerts on. Only available for monitors with groupings. + // For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each new + // cluster violating the alert conditions by setting notify_by to ["cluster"]. Tags mentioned in notify_by must + // be a subset of the grouping tags in the query. For example, a query grouped by cluster and namespace cannot + // notify on region. Setting notify_by to [*] configures the monitor to notify as a simple-alert. + NotifyBy []string `json:"notifyBy,omitempty"` // A Boolean indicating whether this monitor notifies when data stops reporting. NotifyNoData *bool `json:"notifyNoData,omitempty"` // An enum that controls how groups or monitors are treated if an evaluation does not return data points. @@ -115,6 +123,8 @@ type DatadogMonitorOptions struct { // The number of minutes after the last notification before a monitor re-notifies on the current status. // It only re-notifies if it’s not resolved. 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"` // 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"` diff --git a/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go b/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go index 2f04982ec..785feca6e 100644 --- a/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go +++ b/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go @@ -1442,6 +1442,11 @@ func (in *DatadogMonitorOptions) DeepCopyInto(out *DatadogMonitorOptions) { *out = new(bool) **out = **in } + if in.GroupbySimpleMonitor != nil { + in, out := &in.GroupbySimpleMonitor, &out.GroupbySimpleMonitor + *out = new(bool) + **out = **in + } if in.Locked != nil { in, out := &in.Locked, &out.Locked *out = new(bool) @@ -1462,6 +1467,11 @@ func (in *DatadogMonitorOptions) DeepCopyInto(out *DatadogMonitorOptions) { *out = new(bool) **out = **in } + if in.NotifyBy != nil { + in, out := &in.NotifyBy, &out.NotifyBy + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.NotifyNoData != nil { in, out := &in.NotifyNoData, &out.NotifyNoData *out = new(bool) @@ -1472,6 +1482,11 @@ func (in *DatadogMonitorOptions) DeepCopyInto(out *DatadogMonitorOptions) { *out = new(int64) **out = **in } + if in.RenotifyOccurrences != nil { + in, out := &in.RenotifyOccurrences, &out.RenotifyOccurrences + *out = new(int64) + **out = **in + } if in.RequireFullWindow != nil { in, out := &in.RequireFullWindow, &out.RequireFullWindow *out = new(bool) diff --git a/apis/datadoghq/v1alpha1/zz_generated.openapi.go b/apis/datadoghq/v1alpha1/zz_generated.openapi.go index c80df9c6c..67826d412 100644 --- a/apis/datadoghq/v1alpha1/zz_generated.openapi.go +++ b/apis/datadoghq/v1alpha1/zz_generated.openapi.go @@ -2124,6 +2124,13 @@ func schema__apis_datadoghq_v1alpha1_DatadogMonitorOptions(ref common.ReferenceC Format: "", }, }, + "groupbySimpleMonitor": { + SchemaProps: spec.SchemaProps{ + Description: "A Boolean indicating whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.", + Type: []string{"boolean"}, + Format: "", + }, + }, "locked": { SchemaProps: spec.SchemaProps{ Description: "Whether or not the monitor is locked (only editable by creator and admins).", @@ -2159,6 +2166,21 @@ func schema__apis_datadoghq_v1alpha1_DatadogMonitorOptions(ref common.ReferenceC Format: "", }, }, + "notifyBy": { + SchemaProps: spec.SchemaProps{ + Description: "A string indicating the granularity a monitor alerts on. Only available for monitors with groupings. For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each new cluster violating the alert conditions by setting notify_by to [\"cluster\"]. Tags mentioned in notify_by must be a subset of the grouping tags in the query. For example, a query grouped by cluster and namespace cannot notify on region. Setting notify_by to [*] configures the monitor to notify as a simple-alert.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "notifyNoData": { SchemaProps: spec.SchemaProps{ Description: "A Boolean indicating whether this monitor notifies when data stops reporting.", @@ -2180,6 +2202,13 @@ func schema__apis_datadoghq_v1alpha1_DatadogMonitorOptions(ref common.ReferenceC Format: "int64", }, }, + "renotifyOccurrences": { + SchemaProps: spec.SchemaProps{ + Description: "The number of times re-notification messages should be sent on the current status at the provided re-notification interval.", + Type: []string{"integer"}, + Format: "int64", + }, + }, "requireFullWindow": { SchemaProps: spec.SchemaProps{ Description: "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.", diff --git a/config/crd/bases/v1/datadoghq.com_datadogmonitors.yaml b/config/crd/bases/v1/datadoghq.com_datadogmonitors.yaml index 7aa61c60d..17a70b2e1 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogmonitors.yaml +++ b/config/crd/bases/v1/datadoghq.com_datadogmonitors.yaml @@ -78,6 +78,9 @@ spec: description: 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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation. format: int64 type: integer + groupbySimpleMonitor: + description: A Boolean indicating whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold. + type: boolean includeTags: description: A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title. type: boolean @@ -98,6 +101,11 @@ spec: notifyAudit: description: A Boolean indicating whether tagged users are notified on changes to this monitor. type: boolean + notifyBy: + description: A string indicating the granularity a monitor alerts on. Only available for monitors with groupings. For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each new cluster violating the alert conditions by setting notify_by to ["cluster"]. Tags mentioned in notify_by must be a subset of the grouping tags in the query. For example, a query grouped by cluster and namespace cannot notify on region. Setting notify_by to [*] configures the monitor to notify as a simple-alert. + items: + type: string + type: array notifyNoData: description: A Boolean indicating whether this monitor notifies when data stops reporting. type: boolean @@ -108,6 +116,10 @@ spec: description: The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved. format: int64 type: integer + renotifyOccurrences: + 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 requireFullWindow: description: 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. type: boolean diff --git a/config/crd/bases/v1beta1/datadoghq.com_datadogmonitors.yaml b/config/crd/bases/v1beta1/datadoghq.com_datadogmonitors.yaml index a82ac0c16..2ef15f2f6 100644 --- a/config/crd/bases/v1beta1/datadoghq.com_datadogmonitors.yaml +++ b/config/crd/bases/v1beta1/datadoghq.com_datadogmonitors.yaml @@ -79,6 +79,9 @@ spec: description: 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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation. format: int64 type: integer + groupbySimpleMonitor: + description: A Boolean indicating whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold. + type: boolean includeTags: description: A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title. type: boolean @@ -99,6 +102,11 @@ spec: notifyAudit: description: A Boolean indicating whether tagged users are notified on changes to this monitor. type: boolean + notifyBy: + description: A string indicating the granularity a monitor alerts on. Only available for monitors with groupings. For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each new cluster violating the alert conditions by setting notify_by to ["cluster"]. Tags mentioned in notify_by must be a subset of the grouping tags in the query. For example, a query grouped by cluster and namespace cannot notify on region. Setting notify_by to [*] configures the monitor to notify as a simple-alert. + items: + type: string + type: array notifyNoData: description: A Boolean indicating whether this monitor notifies when data stops reporting. type: boolean @@ -109,6 +117,10 @@ spec: description: The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved. format: int64 type: integer + renotifyOccurrences: + 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 requireFullWindow: description: 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. type: boolean diff --git a/controllers/datadogagent/feature/orchestratorexplorer/feature.go b/controllers/datadogagent/feature/orchestratorexplorer/feature.go index 4bdde7576..50cd7cbcf 100644 --- a/controllers/datadogagent/feature/orchestratorexplorer/feature.go +++ b/controllers/datadogagent/feature/orchestratorexplorer/feature.go @@ -16,11 +16,13 @@ import ( apiutils "github.com/DataDog/datadog-operator/apis/utils" "github.com/DataDog/datadog-operator/pkg/controller/utils/comparison" "github.com/DataDog/datadog-operator/pkg/kubernetes" + "github.com/DataDog/datadog-operator/pkg/utils" "github.com/go-logr/logr" apicommon "github.com/DataDog/datadog-operator/apis/datadoghq/common" apicommonv1 "github.com/DataDog/datadog-operator/apis/datadoghq/common/v1" common "github.com/DataDog/datadog-operator/controllers/datadogagent/common" + "github.com/DataDog/datadog-operator/controllers/datadogagent/component" "github.com/DataDog/datadog-operator/controllers/datadogagent/feature" "github.com/DataDog/datadog-operator/controllers/datadogagent/object" "github.com/DataDog/datadog-operator/controllers/datadogagent/object/volume" @@ -60,8 +62,12 @@ type orchestratorExplorerFeature struct { logger logr.Logger customConfigAnnotationKey string customConfigAnnotationValue string + + processAgentRequired bool } +const NoProcessAgentMinVersion = "7.51.0" + // ID returns the ID of the Feature func (f *orchestratorExplorerFeature) ID() feature.IDType { return feature.OrchestratorExplorerIDType @@ -74,9 +80,19 @@ func (f *orchestratorExplorerFeature) Configure(dda *v2alpha1.DatadogAgent) (req if orchestratorExplorer != nil && apiutils.BoolValue(orchestratorExplorer.Enabled) { reqComp.ClusterAgent.IsRequired = apiutils.NewBoolPointer(true) + reqContainers := []apicommonv1.AgentContainerName{apicommonv1.CoreAgentContainerName} + + // Process Agent is not required as of agent version 7.51.0 + if nodeAgent, ok := dda.Spec.Override[v2alpha1.NodeAgentComponentName]; ok { + if nodeAgent.Image != nil && !utils.IsAboveMinVersion(component.GetAgentVersionFromImage(*nodeAgent.Image), NoProcessAgentMinVersion) { + f.processAgentRequired = true + reqContainers = append(reqContainers, apicommonv1.ProcessAgentContainerName) + } + } + reqComp.Agent = feature.RequiredComponent{ IsRequired: apiutils.NewBoolPointer(true), - Containers: []apicommonv1.AgentContainerName{apicommonv1.CoreAgentContainerName, apicommonv1.ProcessAgentContainerName}, + Containers: reqContainers, } if orchestratorExplorer.Conf != nil { @@ -116,6 +132,7 @@ func (f *orchestratorExplorerFeature) Configure(dda *v2alpha1.DatadogAgent) (req func (f *orchestratorExplorerFeature) ConfigureV1(dda *v1alpha1.DatadogAgent) (reqComp feature.RequiredComponents) { f.owner = dda orchestratorExplorer := dda.Spec.Features.OrchestratorExplorer + f.processAgentRequired = true if orchestratorExplorer != nil && apiutils.BoolValue(orchestratorExplorer.Enabled) { reqComp.ClusterAgent.IsRequired = apiutils.NewBoolPointer(true) @@ -231,7 +248,9 @@ func (f *orchestratorExplorerFeature) ManageSingleContainerNodeAgent(managers fe // It should do nothing if the feature doesn't need to configure it. func (f *orchestratorExplorerFeature) ManageNodeAgent(managers feature.PodTemplateManagers, provider string) error { for _, env := range f.getEnvVars() { - managers.EnvVar().AddEnvVarToContainer(apicommonv1.ProcessAgentContainerName, env) + if f.processAgentRequired { + managers.EnvVar().AddEnvVarToContainer(apicommonv1.ProcessAgentContainerName, env) + } managers.EnvVar().AddEnvVarToContainer(apicommonv1.CoreAgentContainerName, env) } diff --git a/controllers/datadogagent/feature/orchestratorexplorer/feature_test.go b/controllers/datadogagent/feature/orchestratorexplorer/feature_test.go index ffce51365..e42e2b35f 100644 --- a/controllers/datadogagent/feature/orchestratorexplorer/feature_test.go +++ b/controllers/datadogagent/feature/orchestratorexplorer/feature_test.go @@ -11,6 +11,7 @@ import ( apicommon "github.com/DataDog/datadog-operator/apis/datadoghq/common" apicommonv1 "github.com/DataDog/datadog-operator/apis/datadoghq/common/v1" + "github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1" v2alpha1test "github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1/test" apiutils "github.com/DataDog/datadog-operator/apis/utils" @@ -67,10 +68,11 @@ func Test_orchestratorExplorerFeature_Configure(t *testing.T) { WithOrchestratorExplorerExtraTags([]string{"a:z", "b:y", "c:x"}). WithOrchestratorExplorerDDUrl("https://foo.bar"). WithOrchestratorExplorerCustomConfigData(customConfDataV2). + WithComponentOverride(v2alpha1.NodeAgentComponentName, v2alpha1.DatadogAgentComponentOverride{Image: &apicommonv1.AgentImageConfig{Tag: "7.51.0"}}). Build(), WantConfigure: true, ClusterAgent: orchestratorExplorerClusterAgentWantFuncV2(), - Agent: test.NewDefaultComponentTest().WithWantFunc(orchestratorExplorerNodeAgentWantFunc), + Agent: test.NewDefaultComponentTest().WithWantFunc(orchestratorExplorerNodeAgentNoProcessAgentWantFunc), }, { Name: "v2alpha1 orchestrator explorer enabled and runs on cluster checks runner", @@ -82,12 +84,27 @@ func Test_orchestratorExplorerFeature_Configure(t *testing.T) { WithOrchestratorExplorerCustomConfigData(customConfDataV2). WithClusterChecksEnabled(true). WithClusterChecksUseCLCEnabled(true). + WithComponentOverride(v2alpha1.NodeAgentComponentName, v2alpha1.DatadogAgentComponentOverride{Image: &apicommonv1.AgentImageConfig{Tag: "7.51.0"}}). Build(), WantConfigure: true, ClusterAgent: orchestratorExplorerClusterAgentWantFuncV2(), - Agent: test.NewDefaultComponentTest().WithWantFunc(orchestratorExplorerNodeAgentWantFunc), + Agent: test.NewDefaultComponentTest().WithWantFunc(orchestratorExplorerNodeAgentNoProcessAgentWantFunc), ClusterChecksRunner: test.NewDefaultComponentTest().WithWantFunc(orchestratorExplorerClusterChecksRunnerWantFunc), }, + { + Name: "v2alpha1 orchestrator explorer enabled on version requiring process agent", + DDAv2: v2alpha1test.NewDatadogAgentBuilder(). + WithOrchestratorExplorerEnabled(true). + WithOrchestratorExplorerScrubContainers(true). + WithOrchestratorExplorerExtraTags([]string{"a:z", "b:y", "c:x"}). + WithOrchestratorExplorerDDUrl("https://foo.bar"). + WithOrchestratorExplorerCustomConfigData(customConfDataV2). + WithComponentOverride(v2alpha1.NodeAgentComponentName, v2alpha1.DatadogAgentComponentOverride{Image: &apicommonv1.AgentImageConfig{Tag: "7.50.0"}}). + Build(), + WantConfigure: true, + ClusterAgent: orchestratorExplorerClusterAgentWantFuncV2(), + Agent: test.NewDefaultComponentTest().WithWantFunc(orchestratorExplorerNodeAgentWantFunc), + }, } tests.Run(t, buildOrchestratorExplorerFeature) @@ -97,6 +114,16 @@ func orchestratorExplorerNodeAgentWantFunc(t testing.TB, mgrInterface feature.Po mgr := mgrInterface.(*fake.PodTemplateManagers) agentEnvVars := mgr.EnvVarMgr.EnvVarsByC[apicommonv1.ProcessAgentContainerName] assert.True(t, apiutils.IsEqualStruct(agentEnvVars, expectedOrchestratorEnvsV2), "Process agent envvars \ndiff = %s", cmp.Diff(agentEnvVars, expectedOrchestratorEnvsV2)) + agentEnvVars = mgr.EnvVarMgr.EnvVarsByC[apicommonv1.CoreAgentContainerName] + assert.True(t, apiutils.IsEqualStruct(agentEnvVars, expectedOrchestratorEnvsV2), "Core agent envvars \ndiff = %s", cmp.Diff(agentEnvVars, expectedOrchestratorEnvsV2)) +} + +func orchestratorExplorerNodeAgentNoProcessAgentWantFunc(t testing.TB, mgrInterface feature.PodTemplateManagers) { + mgr := mgrInterface.(*fake.PodTemplateManagers) + agentEnvVars := mgr.EnvVarMgr.EnvVarsByC[apicommonv1.ProcessAgentContainerName] + assert.True(t, apiutils.IsEqualStruct(agentEnvVars, nil), "Process agent envvars \ndiff = %s", cmp.Diff(agentEnvVars, expectedOrchestratorEnvsV2)) + agentEnvVars = mgr.EnvVarMgr.EnvVarsByC[apicommonv1.CoreAgentContainerName] + assert.True(t, apiutils.IsEqualStruct(agentEnvVars, expectedOrchestratorEnvsV2), "Core agent envvars \ndiff = %s", cmp.Diff(agentEnvVars, expectedOrchestratorEnvsV2)) } func orchestratorExplorerClusterChecksRunnerWantFunc(t testing.TB, mgrInterface feature.PodTemplateManagers) { diff --git a/controllers/datadogmonitor/monitor.go b/controllers/datadogmonitor/monitor.go index a36badc20..6a597f012 100644 --- a/controllers/datadogmonitor/monitor.go +++ b/controllers/datadogmonitor/monitor.go @@ -105,6 +105,10 @@ func buildMonitor(logger logr.Logger, dm *datadoghqv1alpha1.DatadogMonitor) (*da o.SetEvaluationDelay(*options.EvaluationDelay) } + if options.GroupbySimpleMonitor != nil { + o.SetGroupbySimpleMonitor(*options.GroupbySimpleMonitor) + } + if options.IncludeTags != nil { o.SetIncludeTags(*options.IncludeTags) } @@ -129,6 +133,10 @@ func buildMonitor(logger logr.Logger, dm *datadoghqv1alpha1.DatadogMonitor) (*da o.SetNotifyAudit(*options.NotifyAudit) } + if options.NotifyBy != nil { + o.SetNotifyBy(options.NotifyBy) + } + if options.NotifyNoData != nil { o.SetNotifyNoData(*options.NotifyNoData) } @@ -141,6 +149,10 @@ func buildMonitor(logger logr.Logger, dm *datadoghqv1alpha1.DatadogMonitor) (*da o.SetRenotifyInterval(*options.RenotifyInterval) } + if options.RenotifyOccurrences != nil { + o.SetRenotifyOccurrences(*options.RenotifyOccurrences) + } + if options.TimeoutH != nil { o.SetTimeoutH(*options.TimeoutH) } diff --git a/controllers/datadogmonitor/monitor_test.go b/controllers/datadogmonitor/monitor_test.go index 5de4f53dc..829dee2e9 100644 --- a/controllers/datadogmonitor/monitor_test.go +++ b/controllers/datadogmonitor/monitor_test.go @@ -33,6 +33,7 @@ func Test_buildMonitor(t *testing.T) { newGroupDelay := int64(400) noDataTimeframe := int64(15) renotifyInterval := int64(1440) + renotifyOccurrences := int64(1) timeoutH := int64(2) critThreshold := "0.05" warnThreshold := "0.02" @@ -56,14 +57,21 @@ func Test_buildMonitor(t *testing.T) { EvaluationDelay: &evalDelay, EscalationMessage: &escalationMsg, IncludeTags: &valTrue, + GroupbySimpleMonitor: &valTrue, Locked: &valTrue, NewGroupDelay: &newGroupDelay, NoDataTimeframe: &noDataTimeframe, NotificationPresetName: "show_all", - NotifyNoData: &valTrue, - OnMissingData: "default", - RenotifyInterval: &renotifyInterval, - TimeoutH: &timeoutH, + NotifyBy: []string{ + "env", + "kube_namespace", + "kube_cluster", + }, + NotifyNoData: &valTrue, + OnMissingData: "default", + RenotifyOccurrences: &renotifyOccurrences, + RenotifyInterval: &renotifyInterval, + TimeoutH: &timeoutH, Thresholds: &datadoghqv1alpha1.DatadogMonitorOptionsThresholds{ Critical: &critThreshold, Warning: &warnThreshold, @@ -101,6 +109,9 @@ func Test_buildMonitor(t *testing.T) { assert.Equal(t, *dm.Spec.Options.EscalationMessage, monitor.Options.GetEscalationMessage(), "discrepancy found in parameter: EscalationMessage") assert.Equal(t, *dm.Spec.Options.EscalationMessage, monitorUR.Options.GetEscalationMessage(), "discrepancy found in parameter: EscalationMessage") + assert.Equal(t, *dm.Spec.Options.GroupbySimpleMonitor, monitor.Options.GetGroupbySimpleMonitor(), "discrepancy found in parameter: GroupbySimpleMonitor") + assert.Equal(t, *dm.Spec.Options.GroupbySimpleMonitor, monitorUR.Options.GetGroupbySimpleMonitor(), "discrepancy found in parameter: GroupbySimpleMonitor") + assert.Equal(t, *dm.Spec.Options.IncludeTags, monitor.Options.GetIncludeTags(), "discrepancy found in parameter: IncludeTags") assert.Equal(t, *dm.Spec.Options.IncludeTags, monitorUR.Options.GetIncludeTags(), "discrepancy found in parameter: IncludeTags") @@ -116,6 +127,9 @@ func Test_buildMonitor(t *testing.T) { assert.Equal(t, string(dm.Spec.Options.NotificationPresetName), string(monitor.Options.GetNotificationPresetName()), "discrepancy found in parameter: NotificationPresetName") assert.Equal(t, string(dm.Spec.Options.NotificationPresetName), string(monitorUR.Options.GetNotificationPresetName()), "discrepancy found in parameter: NotificationPresetName") + assert.Equal(t, dm.Spec.Options.NotifyBy, monitor.Options.GetNotifyBy(), "discrepancy found in parameter: NotifyBy") + assert.Equal(t, dm.Spec.Options.NotifyBy, monitorUR.Options.GetNotifyBy(), "discrepancy found in parameter: NotifyBy") + assert.Equal(t, *dm.Spec.Options.NotifyNoData, monitor.Options.GetNotifyNoData(), "discrepancy found in parameter: NotifyNoData") assert.Equal(t, *dm.Spec.Options.NotifyNoData, monitorUR.Options.GetNotifyNoData(), "discrepancy found in parameter: NotifyNoData") @@ -125,6 +139,9 @@ func Test_buildMonitor(t *testing.T) { assert.Equal(t, *dm.Spec.Options.RenotifyInterval, monitor.Options.GetRenotifyInterval(), "discrepancy found in parameter: RenotifyInterval") assert.Equal(t, *dm.Spec.Options.RenotifyInterval, monitorUR.Options.GetRenotifyInterval(), "discrepancy found in parameter: RenotifyInterval") + 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.TimeoutH, monitor.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH") assert.Equal(t, *dm.Spec.Options.TimeoutH, monitorUR.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH")