Skip to content
Closed
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
4 changes: 3 additions & 1 deletion api/datadoghq/v1alpha1/datadogmonitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type DatadogMonitorSpec struct {
Tags []string `json:"tags,omitempty"`
// Type is the monitor type
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=metric alert;query alert;service check;event alert;log alert;process alert;rum alert;trace-analytics alert;slo alert;event-v2 alert;audit alert;composite
// +kubebuilder:validation:Enum=metric alert;query alert;service check;event alert;log alert;process alert;rum alert;trace-analytics alert;slo alert;event-v2 alert;audit alert;composite;error-tracking alert
Type DatadogMonitorType `json:"type,omitempty"`
// Options are the optional parameters associated with your monitor
Options DatadogMonitorOptions `json:"options,omitempty"`
Expand Down Expand Up @@ -75,6 +75,8 @@ const (
DatadogMonitorTypeAudit DatadogMonitorType = "audit alert"
// DatadogMonitorTypeComposite is the composite alert monitor type
DatadogMonitorTypeComposite DatadogMonitorType = "composite"
// DatadogMonitorTypeErrorTracking is the error-tracking alert monitor type
DatadogMonitorTypeErrorTracking DatadogMonitorType = "error-tracking alert"
)

// DatadogMonitorOptionsNotificationPreset toggles the display of additional content sent in the monitor notification.
Expand Down
1 change: 1 addition & 0 deletions bundle/manifests/datadoghq.com_datadogmonitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ spec:
- event-v2 alert
- audit alert
- composite
- error-tracking alert
type: string
required:
- message
Expand Down
1 change: 1 addition & 0 deletions config/crd/bases/v1/datadoghq.com_datadogmonitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ spec:
- event-v2 alert
- audit alert
- composite
- error-tracking alert
type: string
required:
- message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@
"slo alert",
"event-v2 alert",
"audit alert",
"composite"
"composite",
"error-tracking alert"
],
"type": "string"
}
Expand Down
1 change: 1 addition & 0 deletions internal/controller/datadogmonitor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var supportedMonitorTypes = map[string]bool{
string(datadogV1.MONITORTYPE_SLO_ALERT): true,
string(datadogV1.MONITORTYPE_EVENT_V2_ALERT): true,
string(datadogV1.MONITORTYPE_AUDIT_ALERT): true,
string(datadogV1.MONITORTYPE_ERROR_TRACKING_ALERT): true,
}

const requiredTag = "generated:kubernetes"
Expand Down
39 changes: 39 additions & 0 deletions internal/controller/datadogmonitor/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,24 @@ func TestReconcileDatadogMonitor_Reconcile(t *testing.T) {
return nil
},
},
{
name: "DatadogMonitor, error-tracking alert",
args: args{
request: newRequest(resourcesNamespace, resourcesName),
loadFunc: testErrorTrackingMonitor,
firstReconcileCount: 10,
},
wantResult: reconcile.Result{RequeueAfter: defaultRequeuePeriod},
wantErr: false,
wantFunc: func(c client.Client) error {
dm := &datadoghqv1alpha1.DatadogMonitor{}
if err := c.Get(context.TODO(), types.NamespacedName{Name: resourcesName, Namespace: resourcesNamespace}, dm); err != nil {
return err
}
assert.NotContains(t, dm.Status.Conditions[0].Message, "error")
return nil
},
},
{
name: "DatadogMonitor of unsupported type (composite)",
args: args{
Expand Down Expand Up @@ -960,6 +978,27 @@ func testAuditMonitor(c client.Client) *datadoghqv1alpha1.DatadogMonitor {
return dm
}

func testErrorTrackingMonitor(c client.Client) *datadoghqv1alpha1.DatadogMonitor {
dm := &datadoghqv1alpha1.DatadogMonitor{
TypeMeta: metav1.TypeMeta{
Kind: "DatadogMonitor",
APIVersion: fmt.Sprintf("%s/%s", datadoghqv1alpha1.GroupVersion.Group, datadoghqv1alpha1.GroupVersion.Version),
},
ObjectMeta: metav1.ObjectMeta{
Namespace: resourcesNamespace,
Name: resourcesName,
},
Spec: datadoghqv1alpha1.DatadogMonitorSpec{
Query: "error-tracking-query",
Type: datadoghqv1alpha1.DatadogMonitorTypeErrorTracking,
Name: "test error tracking monitor",
Message: "something is wrong",
},
}
_ = c.Create(context.TODO(), dm)
return dm
}

// TestReconciler_UpdateDatadogClient tests the UpdateDatadogClient method of the Reconciler
func TestReconciler_UpdateDatadogClient(t *testing.T) {
testLogger := zap.New(zap.UseDevMode(true))
Expand Down
Loading