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

patch - adding label managed-by:coralogix-operator to alerts #26

Merged
merged 1 commit into from
Jul 17, 2023
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
9 changes: 9 additions & 0 deletions controllers/alphacontrollers/alert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ func (r *AlertReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
}

if notFount {
if alertCRD.Spec.Labels == nil {
alertCRD.Spec.Labels = make(map[string]string)
}
alertCRD.Spec.Labels["managed-by"] = "coralogix-operator"
if err := r.Client.Update(ctx, alertCRD); err != nil {
log.Error(err, "Error on updating alert", "Name", alertCRD.Name, "Namespace", alertCRD.Namespace)
return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err
}

createAlertReq, err := alertCRD.Spec.ExtractCreateAlertRequest()
if err != nil {
log.Error(err, "Bad request for creating alert", "Name", alertCRD.Name, "Namespace", alertCRD.Namespace)
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/alerts/lucene/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ status:
searchQuery: name:\"Frontend transactions\"
description: alert from k8s operator
name: lucene alert example
labels:
managed-by: coralogix-operator
# notificationGroups:
# - notifications:
# - notifyOn: TriggeredOnly
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/alerts/new-value/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ status:
- Error
description: alert from k8s operator
name: new-value alert example
labels:
managed-by: coralogix-operator
# notificationGroups:
# - notifications:
# - notifyOn: TriggeredOnly
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/alerts/promql/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ status:
searchQuery: http_requests_total{status!~\"4..\"}
description: alert from k8s operator
name: promql alert example
labels:
managed-by: coralogix-operator
# notificationGroups:
# - notifications:
# - notifyOn: TriggeredOnly
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/alerts/ratio/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ status:
- filter:startsWith:subsystem-name
description: alert from k8s operator
name: ratio alert example
labels:
managed-by: coralogix-operator
# notificationGroups:
# - notifications:
# - notifyOn: TriggeredOnly
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/alerts/standard/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ status:
labels:
alert_type: security
security_severity: high
managed-by: coralogix-operator
name: standard alert example
# notificationGroups:
# - notifications:
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/alerts/time-relative/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ status:
labels:
alert_type: security
security_severity: high
managed-by: coralogix-operator
name: time-relative alert example
# notificationGroups:
# - notifications:
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/alerts/trace/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ status:
- filter:contains:400
description: alert from k8s operator
name: tracing alert example
labels:
managed-by: coralogix-operator
# notificationGroups:
# - notifications:
# - notifyOn: TriggeredOnly
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/alerts/unique-count/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ status:
- Error
description: alert from k8s operator
name: unique-count alert example
labels:
managed-by: coralogix-operator
# notificationGroups:
# - notifications:
# - notifyOn: TriggeredOnly
Expand Down
Loading