From e8d162bc7146ee61f6ea149ec6291bb8f732dfa7 Mon Sep 17 00:00:00 2001 From: "assaf.admi" Date: Sun, 20 Oct 2024 13:01:39 +0300 Subject: [PATCH] Improve resources status --- Makefile | 2 +- apis/coralogix/v1alpha1/alert_types.go | 132 - .../v1alpha1/outboundwebhook_types.go | 104 - .../v1alpha1/recordingrulegroupset_types.go | 24 - apis/coralogix/v1alpha1/rulegroup_types.go | 117 - .../v1alpha1/zz_generated.deepcopy.go | 139 - .../templates/crds/coralogix.com_alerts.yaml | 891 ---- .../crds/coralogix.com_outboundwebhooks.yaml | 153 - .../coralogix.com_recordingrulegroupsets.yaml | 30 - .../crds/coralogix.com_rulegroups.yaml | 190 - config/crd/bases/coralogix.com_alerts.yaml | 891 ---- .../bases/coralogix.com_outboundwebhooks.yaml | 153 - .../coralogix.com_recordingrulegroupsets.yaml | 30 - .../crd/bases/coralogix.com_rulegroups.yaml | 190 - .../alphacontrollers/alert_controller.go | 825 +--- .../alphacontrollers/alert_controller_test.go | 41 +- .../outboundwebhook_controller.go | 188 +- .../alphacontrollers/rulegroup_controller.go | 200 +- .../rulegroup_controller_test.go | 32 +- docs/api.md | 4268 ++--------------- kuttl-test.yaml | 4 - .../alertmangerconfig-basic/02-assert.yaml | 15 - .../alertmangerconfig-basic/03-assert.yaml | 101 - .../alertmangerconfig-basic/05-assert.yaml | 94 - .../prometheusrules-basic/01-assert.yaml | 19 - .../prometheusrules-basic/02-assert.yaml | 19 - .../prometheusrules-basic/04-assert.yaml | 19 - .../prometheusrules-basic/05-assert.yaml | 19 - 28 files changed, 405 insertions(+), 8485 deletions(-) diff --git a/Makefile b/Makefile index 5fd733d..bb6a3e8 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - .PHONY: deploy -deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. +deploy: manifests kustomize install ## Deploy controller to the K8s cluster specified in ~/.kube/config. # Step 1: Set the image in the manager deployment cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} diff --git a/apis/coralogix/v1alpha1/alert_types.go b/apis/coralogix/v1alpha1/alert_types.go index ee28ec9..6fc7b2c 100644 --- a/apis/coralogix/v1alpha1/alert_types.go +++ b/apis/coralogix/v1alpha1/alert_types.go @@ -1082,116 +1082,6 @@ func expandNotification(notification Notification, webhooksNameToIds map[string] return result, nil } -func (in *AlertSpec) DeepEqual(actualAlert *AlertStatus) (bool, utils.Diff) { - if actualName := actualAlert.Name; actualName != in.Name { - return false, utils.Diff{ - Name: "Name", - Desired: in.Name, - Actual: actualName, - } - } - - if actualDescription := actualAlert.Description; actualDescription != in.Description { - return false, utils.Diff{ - Name: "Description", - Desired: in.Description, - Actual: actualDescription, - } - } - - if actualActive := actualAlert.Active; actualActive != in.Active { - return false, utils.Diff{ - Name: "Active", - Desired: in.Active, - Actual: actualActive, - } - } - - if actualSeverity := actualAlert.Severity; actualSeverity != in.Severity { - return false, utils.Diff{ - Name: "Severity", - Desired: in.Severity, - Actual: actualSeverity, - } - } - - if !reflect.DeepEqual(in.Labels, actualAlert.Labels) { - return false, utils.Diff{ - Name: "Labels", - Desired: in.Labels, - Actual: actualAlert.Labels, - } - } - - if !reflect.DeepEqual(in.ExpirationDate, actualAlert.ExpirationDate) { - return false, utils.Diff{ - Name: "ExpirationDate", - Desired: utils.PointerToString(in.ExpirationDate), - Actual: utils.PointerToString(actualAlert.ExpirationDate), - } - } - - if equal, diff := in.AlertType.DeepEqual(actualAlert.AlertType); !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("AlertType.%s", diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - - notificationGroups, actualNotificationGroups := in.NotificationGroups, actualAlert.NotificationGroups - { - if equal, diff := DeepEqualNotificationGroups(notificationGroups, actualNotificationGroups); !equal { - return false, diff - } - } - - if !utils.SlicesWithUniqueValuesEqual(in.PayloadFilters, actualAlert.PayloadFilters) { - return false, utils.Diff{ - Name: "PayloadFilters", - Desired: in.PayloadFilters, - Actual: actualAlert.PayloadFilters, - } - } - - if scheduling, actualScheduling := in.Scheduling, actualAlert.Scheduling; (scheduling == nil && actualScheduling != nil) || (scheduling != nil && actualScheduling == nil) { - return false, utils.Diff{ - Name: "Scheduling", - Desired: scheduling, - Actual: actualScheduling, - } - } else if actualScheduling == nil { - - } else if equal, diff := scheduling.DeepEqual(*actualScheduling); !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("Scheduling.%s", diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - - showInInsight, actualShowInInsight := in.ShowInInsight, actualAlert.ShowInInsight - { - if showInInsight != nil { - if actualShowInInsight == nil { - return false, utils.Diff{ - Name: "ShowInInsight", - Desired: *showInInsight, - Actual: actualShowInInsight, - } - } else if equal, diff := showInInsight.DeepEqual(*actualShowInInsight); !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("ShowInInsight.%s", diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - } - } - - return true, utils.Diff{} -} - func DeepEqualNotificationGroups(notificationGroups []NotificationGroup, actualNotificationGroups []NotificationGroup) (bool, utils.Diff) { if length, actualLength := len(notificationGroups), len(actualNotificationGroups); length != actualLength { return false, utils.Diff{ @@ -3078,28 +2968,6 @@ type FlowOperator string // AlertStatus defines the observed state of Alert type AlertStatus struct { ID *string `json:"id"` - - Name string `json:"name,omitempty"` - - Description string `json:"description,omitempty"` - - Active bool `json:"active,omitempty"` - - Severity AlertSeverity `json:"severity,omitempty"` - - Labels map[string]string `json:"labels,omitempty"` - - ExpirationDate *ExpirationDate `json:"expirationDate,omitempty"` - - ShowInInsight *ShowInInsight `json:"showInInsight,omitempty"` - - NotificationGroups []NotificationGroup `json:"notificationGroups,omitempty"` - - PayloadFilters []string `json:"payloadFilters,omitempty"` - - Scheduling *Scheduling `json:"scheduling,omitempty"` - - AlertType AlertType `json:"alertType,omitempty"` } func NewDefaultAlertStatus() *AlertStatus { diff --git a/apis/coralogix/v1alpha1/outboundwebhook_types.go b/apis/coralogix/v1alpha1/outboundwebhook_types.go index c6369ae..7cc6476 100644 --- a/apis/coralogix/v1alpha1/outboundwebhook_types.go +++ b/apis/coralogix/v1alpha1/outboundwebhook_types.go @@ -71,28 +71,6 @@ type OutboundWebhookType struct { AwsEventBridge *AwsEventBridge `json:"awsEventBridge,omitempty"` } -type OutboundWebhookTypeStatus struct { - GenericWebhook *GenericWebhookStatus `json:"genericWebhook,omitempty"` - - Slack *Slack `json:"slack,omitempty"` - - PagerDuty *PagerDuty `json:"pagerDuty,omitempty"` - - SendLog *SendLogStatus `json:"sendLog,omitempty"` - - EmailGroup *EmailGroup `json:"emailGroup,omitempty"` - - MicrosoftTeams *MicrosoftTeams `json:"microsoftTeams,omitempty"` - - Jira *Jira `json:"jira,omitempty"` - - Opsgenie *Opsgenie `json:"opsgenie,omitempty"` - - Demisto *Demisto `json:"demisto,omitempty"` - - AwsEventBridge *AwsEventBridge `json:"awsEventBridge,omitempty"` -} - func (in *OutboundWebhookType) appendOutgoingWebhookConfig(data *cxsdk.OutgoingWebhookInputData) (*cxsdk.OutgoingWebhookInputData, error) { if genericWebhook := in.GenericWebhook; genericWebhook != nil { data.Config = genericWebhook.extractGenericWebhookConfig() @@ -138,55 +116,6 @@ func (in *OutboundWebhookType) appendOutgoingWebhookConfig(data *cxsdk.OutgoingW return data, nil } -func (in *OutboundWebhookType) DeepEqual(webhookType *OutboundWebhookTypeStatus) (bool, utils.Diff) { - if webhookType == nil { - return false, utils.Diff{ - Name: "OutboundWebhookType", - Desired: utils.PointerToString(in), - Actual: nil, - } - } - - equal, diff := true, utils.Diff{} - if desiredGenericWebhook, actualGenericWebhook := in.GenericWebhook, webhookType.GenericWebhook; desiredGenericWebhook != nil { - equal, diff = desiredGenericWebhook.DeepEqual(actualGenericWebhook) - } else if desiredSlack, actualSlack := in.Slack, webhookType.Slack; desiredSlack != nil { - equal, diff = desiredSlack.DeepEqual(actualSlack) - } else if desiredPagerDuty, actualPagerDuty := in.PagerDuty, webhookType.PagerDuty; desiredPagerDuty != nil { - equal, diff = desiredPagerDuty.DeepEqual(actualPagerDuty) - } else if desiredSendLog, actualSendLog := in.SendLog, webhookType.SendLog; desiredSendLog != nil { - equal, diff = desiredSendLog.DeepEqual(actualSendLog) - } else if desiredEmailGroup, actualEmailGroup := in.EmailGroup, webhookType.EmailGroup; desiredEmailGroup != nil { - equal, diff = desiredEmailGroup.DeepEqual(actualEmailGroup) - } else if desiredMicrosoftTeams, actualMicrosoftTeams := in.MicrosoftTeams, webhookType.MicrosoftTeams; desiredMicrosoftTeams != nil { - equal, diff = desiredMicrosoftTeams.DeepEqual(actualMicrosoftTeams) - } else if desiredJira, actualJira := in.Jira, webhookType.Jira; desiredJira != nil { - equal, diff = desiredJira.DeepEqual(actualJira) - } else if desiredOpsgenie, actualOpsgenie := in.Opsgenie, webhookType.Opsgenie; desiredOpsgenie != nil { - equal, diff = desiredOpsgenie.DeepEqual(actualOpsgenie) - } else if desiredDemisto, actualDemisto := in.Demisto, webhookType.Demisto; desiredDemisto != nil { - equal, diff = desiredDemisto.DeepEqual(actualDemisto) - } else if desiredAwsEventBridge, actualAwsEventBridge := in.AwsEventBridge, webhookType.AwsEventBridge; desiredAwsEventBridge != nil { - equal, diff = desiredAwsEventBridge.DeepEqual(actualAwsEventBridge) - } else { - return false, utils.Diff{ - Name: "OutboundWebhookType", - Desired: utils.PointerToString(in), - Actual: utils.PointerToString(webhookType), - } - } - - if !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("OutboundWebhookType.%s", diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - - return true, utils.Diff{} -} - type GenericWebhook struct { Url string `json:"url"` @@ -767,10 +696,6 @@ type OutboundWebhookStatus struct { // +optional ExternalID *string `json:"externalId"` - - Name string `json:"name"` - - OutboundWebhookType *OutboundWebhookTypeStatus `json:"outboundWebhookType"` } //+kubebuilder:object:root=true @@ -812,35 +737,6 @@ func (in *OutboundWebhook) ExtractUpdateOutboundWebhookRequest() (*cxsdk.UpdateO }, nil } -func (in *OutboundWebhookSpec) DeepEqual(status *OutboundWebhookStatus) (bool, utils.Diff) { - if status == nil { - return false, utils.Diff{ - Name: "OutboundWebhookStatus", - Desired: utils.PointerToString(in), - Actual: nil, - } - } - - if in.Name != status.Name { - return false, utils.Diff{ - Name: "OutboundWebhookStatus.Name", - Desired: in.Name, - Actual: status.Name, - } - } - - equal, diff := in.OutboundWebhookType.DeepEqual(status.OutboundWebhookType) - if !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("OutboundWebhookStatus.OutboundWebhookType.%s", diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - - return true, utils.Diff{} -} - func (in *OutboundWebhookSpec) ExtractOutgoingWebhookInputData() (*cxsdk.OutgoingWebhookInputData, error) { webhookData := &cxsdk.OutgoingWebhookInputData{ Name: wrapperspb.String(in.Name), diff --git a/apis/coralogix/v1alpha1/recordingrulegroupset_types.go b/apis/coralogix/v1alpha1/recordingrulegroupset_types.go index e6f7713..d59dd94 100644 --- a/apis/coralogix/v1alpha1/recordingrulegroupset_types.go +++ b/apis/coralogix/v1alpha1/recordingrulegroupset_types.go @@ -36,28 +36,6 @@ type RecordingRuleGroupSetSpec struct { Groups []RecordingRuleGroup `json:"groups"` } -func (in *RecordingRuleGroupSetSpec) DeepEqual(status RecordingRuleGroupSetStatus) (bool, utils.Diff) { - if length, actualLength := len(in.Groups), len(status.Groups); length != actualLength { - return false, utils.Diff{ - Name: "Groups.Length", - Desired: length, - Actual: actualLength, - } - } - - for i := range in.Groups { - if equal, diff := in.Groups[i].DeepEqual(status.Groups[i]); !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("Groups.%d.%s", i, diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - } - - return true, utils.Diff{} -} - func (in *RecordingRuleGroupSetSpec) ExtractRecordingRuleGroups() []*cxsdk.InRuleGroup { result := make([]*cxsdk.InRuleGroup, 0, len(in.Groups)) for _, ruleGroup := range in.Groups { @@ -208,8 +186,6 @@ type RecordingRule struct { // RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet type RecordingRuleGroupSetStatus struct { ID *string `json:"id"` - - Groups []RecordingRuleGroup `json:"groups,omitempty"` } //+kubebuilder:object:root=true diff --git a/apis/coralogix/v1alpha1/rulegroup_types.go b/apis/coralogix/v1alpha1/rulegroup_types.go index 89c3dff..c8ab5c1 100644 --- a/apis/coralogix/v1alpha1/rulegroup_types.go +++ b/apis/coralogix/v1alpha1/rulegroup_types.go @@ -710,103 +710,6 @@ func (in *RuleGroupSpec) ToString() string { return string(str) } -func (in *RuleGroupSpec) DeepEqual(actualRuleGroup RuleGroupStatus) (bool, utils.Diff) { - if actualName := actualRuleGroup.Name; in.Name != actualName { - return false, utils.Diff{ - Name: "Name", - Desired: in.Name, - Actual: actualName, - } - } - - if actualDescription := actualRuleGroup.Description; in.Description != actualDescription { - return false, utils.Diff{ - Name: "Description", - Desired: in.Description, - Actual: actualDescription, - } - } - - if actualActive := actualRuleGroup.Active; in.Active != actualActive { - return false, utils.Diff{ - Name: "Active", - Desired: in.Active, - Actual: actualActive, - } - } - - if actualHidden := actualRuleGroup.Hidden; in.Hidden != actualHidden { - return false, utils.Diff{ - Name: "Hidden", - Desired: in.Hidden, - Actual: actualHidden, - } - } - - if actualCreator := actualRuleGroup.Creator; in.Creator != actualCreator { - return false, utils.Diff{ - Name: "Creator", - Desired: in.Creator, - Actual: actualCreator, - } - } - - if in.Order == nil { - in.Order = new(int32) - *in.Order = *actualRuleGroup.Order - } else if actualOrder := actualRuleGroup.Order; *in.Order != *actualOrder { - return false, utils.Diff{ - Name: "Order", - Desired: *in.Order, - Actual: actualOrder, - } - } - - if !utils.SlicesWithUniqueValuesEqual(in.Applications, actualRuleGroup.Applications) { - return false, utils.Diff{ - Name: "Applications", - Desired: in.Applications, - Actual: actualRuleGroup.Applications, - } - } - - if !utils.SlicesWithUniqueValuesEqual(in.Subsystems, actualRuleGroup.Subsystems) { - return false, utils.Diff{ - Name: "Subsystems", - Desired: in.Subsystems, - Actual: actualRuleGroup.Subsystems, - } - } - - if !utils.SlicesWithUniqueValuesEqual(in.Severities, actualRuleGroup.Severities) { - return false, utils.Diff{ - Name: "Severities", - Desired: in.Severities, - Actual: actualRuleGroup.Severities, - } - } - - if len(in.RuleSubgroups) != len(actualRuleGroup.RuleSubgroups) { - return false, utils.Diff{ - Name: "RuleSubgroups length", - Desired: len(in.RuleSubgroups), - Actual: len(actualRuleGroup.RuleSubgroups), - } - } - - for i := range in.RuleSubgroups { - if equal, diff := in.RuleSubgroups[i].DeepEqual(actualRuleGroup.RuleSubgroups[i]); !equal { - return false, utils.Diff{ - Name: fmt.Sprintf("RuleSubgroups[%d].%s", i, diff.Name), - Desired: diff.Desired, - Actual: diff.Actual, - } - } - } - - return true, utils.Diff{} -} - func (in *RuleGroupSpec) ExtractUpdateRuleGroupRequest(id string) *cxsdk.UpdateRuleGroupRequest { ruleGroup := in.ExtractCreateRuleGroupRequest() return &cxsdk.UpdateRuleGroupRequest{ @@ -1051,26 +954,6 @@ type RuleGroupStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file ID *string `json:"id"` - - Name string `json:"name,omitempty"` - - Description string `json:"description,omitempty"` - - Active bool `json:"active,omitempty"` - - Applications []string `json:"applications,omitempty"` - - Subsystems []string `json:"subsystems,omitempty"` - - Severities []RuleSeverity `json:"severities,omitempty"` - - Hidden bool `json:"hidden,omitempty"` - - Creator string `json:"creator,omitempty"` - - Order *int32 `json:"order,omitempty"` - - RuleSubgroups []RuleSubGroup `json:"subgroups,omitempty"` } //+kubebuilder:object:root=true diff --git a/apis/coralogix/v1alpha1/zz_generated.deepcopy.go b/apis/coralogix/v1alpha1/zz_generated.deepcopy.go index 9c4bd2f..3405e81 100644 --- a/apis/coralogix/v1alpha1/zz_generated.deepcopy.go +++ b/apis/coralogix/v1alpha1/zz_generated.deepcopy.go @@ -141,41 +141,6 @@ func (in *AlertStatus) DeepCopyInto(out *AlertStatus) { *out = new(string) **out = **in } - if in.Labels != nil { - in, out := &in.Labels, &out.Labels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ExpirationDate != nil { - in, out := &in.ExpirationDate, &out.ExpirationDate - *out = new(ExpirationDate) - **out = **in - } - if in.ShowInInsight != nil { - in, out := &in.ShowInInsight, &out.ShowInInsight - *out = new(ShowInInsight) - **out = **in - } - if in.NotificationGroups != nil { - in, out := &in.NotificationGroups, &out.NotificationGroups - *out = make([]NotificationGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.PayloadFilters != nil { - in, out := &in.PayloadFilters, &out.PayloadFilters - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Scheduling != nil { - in, out := &in.Scheduling, &out.Scheduling - *out = new(Scheduling) - (*in).DeepCopyInto(*out) - } - in.AlertType.DeepCopyInto(&out.AlertType) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlertStatus. @@ -935,11 +900,6 @@ func (in *OutboundWebhookStatus) DeepCopyInto(out *OutboundWebhookStatus) { *out = new(string) **out = **in } - if in.OutboundWebhookType != nil { - in, out := &in.OutboundWebhookType, &out.OutboundWebhookType - *out = new(OutboundWebhookTypeStatus) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutboundWebhookStatus. @@ -1017,71 +977,6 @@ func (in *OutboundWebhookType) DeepCopy() *OutboundWebhookType { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OutboundWebhookTypeStatus) DeepCopyInto(out *OutboundWebhookTypeStatus) { - *out = *in - if in.GenericWebhook != nil { - in, out := &in.GenericWebhook, &out.GenericWebhook - *out = new(GenericWebhookStatus) - (*in).DeepCopyInto(*out) - } - if in.Slack != nil { - in, out := &in.Slack, &out.Slack - *out = new(Slack) - (*in).DeepCopyInto(*out) - } - if in.PagerDuty != nil { - in, out := &in.PagerDuty, &out.PagerDuty - *out = new(PagerDuty) - **out = **in - } - if in.SendLog != nil { - in, out := &in.SendLog, &out.SendLog - *out = new(SendLogStatus) - **out = **in - } - if in.EmailGroup != nil { - in, out := &in.EmailGroup, &out.EmailGroup - *out = new(EmailGroup) - (*in).DeepCopyInto(*out) - } - if in.MicrosoftTeams != nil { - in, out := &in.MicrosoftTeams, &out.MicrosoftTeams - *out = new(MicrosoftTeams) - **out = **in - } - if in.Jira != nil { - in, out := &in.Jira, &out.Jira - *out = new(Jira) - **out = **in - } - if in.Opsgenie != nil { - in, out := &in.Opsgenie, &out.Opsgenie - *out = new(Opsgenie) - **out = **in - } - if in.Demisto != nil { - in, out := &in.Demisto, &out.Demisto - *out = new(Demisto) - **out = **in - } - if in.AwsEventBridge != nil { - in, out := &in.AwsEventBridge, &out.AwsEventBridge - *out = new(AwsEventBridge) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutboundWebhookTypeStatus. -func (in *OutboundWebhookTypeStatus) DeepCopy() *OutboundWebhookTypeStatus { - if in == nil { - return nil - } - out := new(OutboundWebhookTypeStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PagerDuty) DeepCopyInto(out *PagerDuty) { *out = *in @@ -1431,13 +1326,6 @@ func (in *RecordingRuleGroupSetStatus) DeepCopyInto(out *RecordingRuleGroupSetSt *out = new(string) **out = **in } - if in.Groups != nil { - in, out := &in.Groups, &out.Groups - *out = make([]RecordingRuleGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecordingRuleGroupSetStatus. @@ -1654,33 +1542,6 @@ func (in *RuleGroupStatus) DeepCopyInto(out *RuleGroupStatus) { *out = new(string) **out = **in } - if in.Applications != nil { - in, out := &in.Applications, &out.Applications - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Subsystems != nil { - in, out := &in.Subsystems, &out.Subsystems - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Severities != nil { - in, out := &in.Severities, &out.Severities - *out = make([]RuleSeverity, len(*in)) - copy(*out, *in) - } - if in.Order != nil { - in, out := &in.Order, &out.Order - *out = new(int32) - **out = **in - } - if in.RuleSubgroups != nil { - in, out := &in.RuleSubgroups, &out.RuleSubgroups - *out = make([]RuleSubGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleGroupStatus. diff --git a/charts/coralogix-operator/templates/crds/coralogix.com_alerts.yaml b/charts/coralogix-operator/templates/crds/coralogix.com_alerts.yaml index d693c86..b2aea4c 100644 --- a/charts/coralogix-operator/templates/crds/coralogix.com_alerts.yaml +++ b/charts/coralogix-operator/templates/crds/coralogix.com_alerts.yaml @@ -940,899 +940,8 @@ spec: status: description: AlertStatus defines the observed state of Alert properties: - active: - type: boolean - alertType: - properties: - flow: - properties: - stages: - items: - properties: - groups: - items: - properties: - innerFlowAlerts: - properties: - alerts: - items: - properties: - not: - default: false - type: boolean - userAlertId: - type: string - type: object - type: array - operator: - enum: - - And - - Or - type: string - required: - - alerts - - operator - type: object - nextOperator: - enum: - - And - - Or - type: string - required: - - innerFlowAlerts - - nextOperator - type: object - type: array - timeWindow: - properties: - hours: - type: integer - minutes: - type: integer - seconds: - type: integer - type: object - required: - - groups - type: object - type: array - required: - - stages - type: object - metric: - properties: - lucene: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - type: string - arithmeticOperator: - enum: - - Avg - - Min - - Max - - Sum - - Count - - Percentile - type: string - arithmeticOperatorModifier: - type: integer - groupBy: - items: - type: string - type: array - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - metricField: - type: string - minNonNullValuesPercentage: - minimum: 0 - multipleOf: 10 - type: integer - replaceMissingValueWithZero: - default: false - type: boolean - sampleThresholdPercentage: - minimum: 0 - multipleOf: 10 - type: integer - threshold: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - Minute - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - required: - - alertWhen - - arithmeticOperator - - metricField - - threshold - - timeWindow - type: object - searchQuery: - type: string - required: - - conditions - type: object - promql: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - - MoreThanUsual - type: string - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - minNonNullValuesPercentage: - minimum: 0 - multipleOf: 10 - type: integer - replaceMissingValueWithZero: - type: boolean - sampleThresholdPercentage: - minimum: 0 - multipleOf: 10 - type: integer - threshold: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - Minute - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - required: - - alertWhen - - threshold - - timeWindow - type: object - searchQuery: - type: string - required: - - conditions - type: object - type: object - newValue: - properties: - conditions: - properties: - key: - type: string - timeWindow: - enum: - - TwelveHours - - TwentyFourHours - - FortyEightHours - - SeventTwoHours - - Week - - Month - - TwoMonths - - ThreeMonths - type: string - required: - - key - - timeWindow - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - ratio: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - type: string - groupBy: - items: - type: string - type: array - groupByFor: - enum: - - Q1 - - Q2 - - Both - type: string - ignoreInfinity: - default: false - type: boolean - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - ratio: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - alertWhen - - ratio - - timeWindow - type: object - q1Filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - q2Filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - standard: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - - Immediately - - MoreThanUsual - type: string - groupBy: - items: - type: string - type: array - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - threshold: - type: integer - timeWindow: - enum: - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - alertWhen - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - timeRelative: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - type: string - groupBy: - items: - type: string - type: array - ignoreInfinity: - default: false - type: boolean - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - threshold: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - PreviousHour - - SameHourYesterday - - SameHourLastWeek - - Yesterday - - SameDayLastWeek - - SameDayLastMonth - type: string - required: - - alertWhen - - threshold - - timeWindow - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - tracing: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Immediately - type: string - groupBy: - items: - type: string - type: array - threshold: - type: integer - timeWindow: - enum: - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - alertWhen - type: object - filters: - properties: - applications: - items: - type: string - type: array - latencyThresholdMilliseconds: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - services: - items: - type: string - type: array - subsystems: - items: - type: string - type: array - tagFilters: - items: - properties: - field: - type: string - values: - items: - type: string - type: array - type: object - type: array - type: object - required: - - conditions - type: object - uniqueCount: - properties: - conditions: - properties: - groupBy: - type: string - key: - type: string - maxUniqueValues: - minimum: 1 - type: integer - maxUniqueValuesForGroupBy: - minimum: 1 - type: integer - timeWindow: - enum: - - Minute - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - key - - maxUniqueValues - - timeWindow - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - type: object - description: - type: string - expirationDate: - properties: - day: - format: int32 - maximum: 31 - minimum: 1 - type: integer - month: - format: int32 - maximum: 12 - minimum: 1 - type: integer - year: - format: int32 - maximum: 9999 - minimum: 1 - type: integer - type: object id: type: string - labels: - additionalProperties: - type: string - type: object - name: - type: string - notificationGroups: - items: - properties: - groupByFields: - items: - type: string - type: array - notifications: - items: - properties: - emailRecipients: - items: - type: string - type: array - integrationName: - type: string - notifyOn: - enum: - - TriggeredOnly - - TriggeredAndResolved - type: string - retriggeringPeriodMinutes: - format: int32 - type: integer - type: object - type: array - type: object - type: array - payloadFilters: - items: - type: string - type: array - scheduling: - properties: - daysEnabled: - items: - enum: - - Sunday - - Monday - - Tuesday - - Wednesday - - Thursday - - Friday - - Saturday - type: string - type: array - endTime: - pattern: ^(0\d|1\d|2[0-3]):[0-5]\d$ - type: string - startTime: - pattern: ^(0\d|1\d|2[0-3]):[0-5]\d$ - type: string - timeZone: - default: UTC+00 - pattern: ^UTC[+-]\d{2}$ - type: string - type: object - severity: - enum: - - Info - - Warning - - Critical - - Error - type: string - showInInsight: - properties: - notifyOn: - default: TriggeredOnly - enum: - - TriggeredOnly - - TriggeredAndResolved - type: string - retriggeringPeriodMinutes: - format: int32 - minimum: 1 - type: integer - type: object required: - id type: object diff --git a/charts/coralogix-operator/templates/crds/coralogix.com_outboundwebhooks.yaml b/charts/coralogix-operator/templates/crds/coralogix.com_outboundwebhooks.yaml index af1f86a..22d944a 100644 --- a/charts/coralogix-operator/templates/crds/coralogix.com_outboundwebhooks.yaml +++ b/charts/coralogix-operator/templates/crds/coralogix.com_outboundwebhooks.yaml @@ -196,161 +196,8 @@ spec: type: string id: type: string - name: - type: string - outboundWebhookType: - properties: - awsEventBridge: - properties: - detail: - type: string - detailType: - type: string - eventBusArn: - type: string - roleName: - type: string - source: - type: string - required: - - detail - - detailType - - eventBusArn - - roleName - - source - type: object - demisto: - properties: - payload: - type: string - url: - type: string - uuid: - type: string - required: - - payload - - url - - uuid - type: object - emailGroup: - properties: - emailAddresses: - items: - type: string - type: array - required: - - emailAddresses - type: object - genericWebhook: - properties: - headers: - additionalProperties: - type: string - type: object - method: - enum: - - Unkown - - Get - - Post - - Put - type: string - payload: - type: string - url: - type: string - uuid: - type: string - required: - - method - - url - - uuid - type: object - jira: - properties: - apiToken: - type: string - email: - type: string - projectKey: - type: string - url: - type: string - required: - - apiToken - - email - - projectKey - - url - type: object - microsoftTeams: - properties: - url: - type: string - required: - - url - type: object - opsgenie: - properties: - url: - type: string - required: - - url - type: object - pagerDuty: - properties: - serviceKey: - type: string - required: - - serviceKey - type: object - sendLog: - properties: - payload: - type: string - url: - type: string - uuid: - type: string - required: - - payload - - url - - uuid - type: object - slack: - properties: - attachments: - items: - properties: - isActive: - type: boolean - type: - type: string - required: - - isActive - - type - type: object - type: array - digests: - items: - properties: - isActive: - type: boolean - type: - type: string - required: - - isActive - - type - type: object - type: array - url: - type: string - required: - - url - type: object - type: object required: - id - - name - - outboundWebhookType type: object type: object served: true diff --git a/charts/coralogix-operator/templates/crds/coralogix.com_recordingrulegroupsets.yaml b/charts/coralogix-operator/templates/crds/coralogix.com_recordingrulegroupsets.yaml index 3311b0c..c68ab0b 100644 --- a/charts/coralogix-operator/templates/crds/coralogix.com_recordingrulegroupsets.yaml +++ b/charts/coralogix-operator/templates/crds/coralogix.com_recordingrulegroupsets.yaml @@ -78,36 +78,6 @@ spec: description: RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet properties: - groups: - items: - properties: - intervalSeconds: - default: 60 - format: int32 - type: integer - limit: - format: int64 - type: integer - name: - description: |- - INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - Important: Run "make" to regenerate code after modifying this file - type: string - rules: - items: - properties: - expr: - type: string - labels: - additionalProperties: - type: string - type: object - record: - type: string - type: object - type: array - type: object - type: array id: type: string required: diff --git a/charts/coralogix-operator/templates/crds/coralogix.com_rulegroups.yaml b/charts/coralogix-operator/templates/crds/coralogix.com_rulegroups.yaml index 33122cf..150e530 100644 --- a/charts/coralogix-operator/templates/crds/coralogix.com_rulegroups.yaml +++ b/charts/coralogix-operator/templates/crds/coralogix.com_rulegroups.yaml @@ -239,201 +239,11 @@ spec: status: description: RuleGroupStatus defines the observed state of RuleGroup properties: - active: - type: boolean - applications: - items: - type: string - type: array - creator: - type: string - description: - type: string - hidden: - type: boolean id: description: |- INSERT ADDITIONAL STATUS FIELD - define observed state of cluster Important: Run "make" to regenerate code after modifying this file type: string - name: - type: string - order: - format: int32 - type: integer - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Error - - Critical - type: string - type: array - subgroups: - items: - properties: - active: - default: true - type: boolean - id: - type: string - order: - format: int32 - type: integer - rules: - items: - properties: - active: - default: true - type: boolean - block: - properties: - blockingAllMatchingBlocks: - default: true - type: boolean - keepBlockedLogs: - default: false - type: boolean - regex: - type: string - sourceField: - type: string - required: - - regex - - sourceField - type: object - description: - type: string - extract: - properties: - regex: - type: string - sourceField: - type: string - required: - - regex - - sourceField - type: object - extractTimestamp: - properties: - fieldFormatStandard: - enum: - - Strftime - - JavaSDF - - Golang - - SecondTS - - MilliTS - - MicroTS - - NanoTS - type: string - sourceField: - type: string - timeFormat: - type: string - required: - - fieldFormatStandard - - sourceField - - timeFormat - type: object - jsonExtract: - properties: - destinationField: - enum: - - Category - - CLASSNAME - - METHODNAME - - THREADID - - SEVERITY - type: string - jsonKey: - type: string - required: - - destinationField - - jsonKey - type: object - jsonStringify: - properties: - destinationField: - type: string - keepSourceField: - default: false - type: boolean - sourceField: - type: string - required: - - destinationField - - sourceField - type: object - name: - minLength: 0 - type: string - parse: - properties: - destinationField: - type: string - regex: - type: string - sourceField: - type: string - required: - - destinationField - - regex - - sourceField - type: object - parseJsonField: - properties: - destinationField: - type: string - keepDestinationField: - type: boolean - keepSourceField: - type: boolean - sourceField: - type: string - required: - - destinationField - - keepDestinationField - - keepSourceField - - sourceField - type: object - removeFields: - properties: - excludedFields: - items: - type: string - type: array - required: - - excludedFields - type: object - replace: - properties: - destinationField: - type: string - regex: - type: string - replacementString: - type: string - sourceField: - type: string - required: - - destinationField - - regex - - replacementString - - sourceField - type: object - required: - - name - type: object - type: array - type: object - type: array - subsystems: - items: - type: string - type: array required: - id type: object diff --git a/config/crd/bases/coralogix.com_alerts.yaml b/config/crd/bases/coralogix.com_alerts.yaml index d693c86..b2aea4c 100644 --- a/config/crd/bases/coralogix.com_alerts.yaml +++ b/config/crd/bases/coralogix.com_alerts.yaml @@ -940,899 +940,8 @@ spec: status: description: AlertStatus defines the observed state of Alert properties: - active: - type: boolean - alertType: - properties: - flow: - properties: - stages: - items: - properties: - groups: - items: - properties: - innerFlowAlerts: - properties: - alerts: - items: - properties: - not: - default: false - type: boolean - userAlertId: - type: string - type: object - type: array - operator: - enum: - - And - - Or - type: string - required: - - alerts - - operator - type: object - nextOperator: - enum: - - And - - Or - type: string - required: - - innerFlowAlerts - - nextOperator - type: object - type: array - timeWindow: - properties: - hours: - type: integer - minutes: - type: integer - seconds: - type: integer - type: object - required: - - groups - type: object - type: array - required: - - stages - type: object - metric: - properties: - lucene: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - type: string - arithmeticOperator: - enum: - - Avg - - Min - - Max - - Sum - - Count - - Percentile - type: string - arithmeticOperatorModifier: - type: integer - groupBy: - items: - type: string - type: array - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - metricField: - type: string - minNonNullValuesPercentage: - minimum: 0 - multipleOf: 10 - type: integer - replaceMissingValueWithZero: - default: false - type: boolean - sampleThresholdPercentage: - minimum: 0 - multipleOf: 10 - type: integer - threshold: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - Minute - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - required: - - alertWhen - - arithmeticOperator - - metricField - - threshold - - timeWindow - type: object - searchQuery: - type: string - required: - - conditions - type: object - promql: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - - MoreThanUsual - type: string - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - minNonNullValuesPercentage: - minimum: 0 - multipleOf: 10 - type: integer - replaceMissingValueWithZero: - type: boolean - sampleThresholdPercentage: - minimum: 0 - multipleOf: 10 - type: integer - threshold: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - Minute - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - required: - - alertWhen - - threshold - - timeWindow - type: object - searchQuery: - type: string - required: - - conditions - type: object - type: object - newValue: - properties: - conditions: - properties: - key: - type: string - timeWindow: - enum: - - TwelveHours - - TwentyFourHours - - FortyEightHours - - SeventTwoHours - - Week - - Month - - TwoMonths - - ThreeMonths - type: string - required: - - key - - timeWindow - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - ratio: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - type: string - groupBy: - items: - type: string - type: array - groupByFor: - enum: - - Q1 - - Q2 - - Both - type: string - ignoreInfinity: - default: false - type: boolean - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - ratio: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - alertWhen - - ratio - - timeWindow - type: object - q1Filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - q2Filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - standard: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - - Immediately - - MoreThanUsual - type: string - groupBy: - items: - type: string - type: array - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - threshold: - type: integer - timeWindow: - enum: - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - alertWhen - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - timeRelative: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Less - type: string - groupBy: - items: - type: string - type: array - ignoreInfinity: - default: false - type: boolean - manageUndetectedValues: - properties: - autoRetireRatio: - default: Never - enum: - - Never - - FiveMinutes - - TenMinutes - - Hour - - TwoHours - - SixHours - - TwelveHours - - TwentyFourHours - type: string - enableTriggeringOnUndetectedValues: - default: true - type: boolean - type: object - threshold: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - timeWindow: - enum: - - PreviousHour - - SameHourYesterday - - SameHourLastWeek - - Yesterday - - SameDayLastWeek - - SameDayLastMonth - type: string - required: - - alertWhen - - threshold - - timeWindow - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - tracing: - properties: - conditions: - properties: - alertWhen: - enum: - - More - - Immediately - type: string - groupBy: - items: - type: string - type: array - threshold: - type: integer - timeWindow: - enum: - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - alertWhen - type: object - filters: - properties: - applications: - items: - type: string - type: array - latencyThresholdMilliseconds: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - services: - items: - type: string - type: array - subsystems: - items: - type: string - type: array - tagFilters: - items: - properties: - field: - type: string - values: - items: - type: string - type: array - type: object - type: array - type: object - required: - - conditions - type: object - uniqueCount: - properties: - conditions: - properties: - groupBy: - type: string - key: - type: string - maxUniqueValues: - minimum: 1 - type: integer - maxUniqueValuesForGroupBy: - minimum: 1 - type: integer - timeWindow: - enum: - - Minute - - FiveMinutes - - TenMinutes - - FifteenMinutes - - TwentyMinutes - - ThirtyMinutes - - Hour - - TwoHours - - FourHours - - SixHours - - TwelveHours - - TwentyFourHours - - ThirtySixHours - type: string - required: - - key - - maxUniqueValues - - timeWindow - type: object - filters: - properties: - alias: - type: string - applications: - items: - type: string - type: array - categories: - items: - type: string - type: array - classes: - items: - type: string - type: array - computers: - items: - type: string - type: array - ips: - items: - type: string - type: array - methods: - items: - type: string - type: array - searchQuery: - type: string - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Critical - - Error - type: string - type: array - subsystems: - items: - type: string - type: array - type: object - required: - - conditions - type: object - type: object - description: - type: string - expirationDate: - properties: - day: - format: int32 - maximum: 31 - minimum: 1 - type: integer - month: - format: int32 - maximum: 12 - minimum: 1 - type: integer - year: - format: int32 - maximum: 9999 - minimum: 1 - type: integer - type: object id: type: string - labels: - additionalProperties: - type: string - type: object - name: - type: string - notificationGroups: - items: - properties: - groupByFields: - items: - type: string - type: array - notifications: - items: - properties: - emailRecipients: - items: - type: string - type: array - integrationName: - type: string - notifyOn: - enum: - - TriggeredOnly - - TriggeredAndResolved - type: string - retriggeringPeriodMinutes: - format: int32 - type: integer - type: object - type: array - type: object - type: array - payloadFilters: - items: - type: string - type: array - scheduling: - properties: - daysEnabled: - items: - enum: - - Sunday - - Monday - - Tuesday - - Wednesday - - Thursday - - Friday - - Saturday - type: string - type: array - endTime: - pattern: ^(0\d|1\d|2[0-3]):[0-5]\d$ - type: string - startTime: - pattern: ^(0\d|1\d|2[0-3]):[0-5]\d$ - type: string - timeZone: - default: UTC+00 - pattern: ^UTC[+-]\d{2}$ - type: string - type: object - severity: - enum: - - Info - - Warning - - Critical - - Error - type: string - showInInsight: - properties: - notifyOn: - default: TriggeredOnly - enum: - - TriggeredOnly - - TriggeredAndResolved - type: string - retriggeringPeriodMinutes: - format: int32 - minimum: 1 - type: integer - type: object required: - id type: object diff --git a/config/crd/bases/coralogix.com_outboundwebhooks.yaml b/config/crd/bases/coralogix.com_outboundwebhooks.yaml index af1f86a..22d944a 100644 --- a/config/crd/bases/coralogix.com_outboundwebhooks.yaml +++ b/config/crd/bases/coralogix.com_outboundwebhooks.yaml @@ -196,161 +196,8 @@ spec: type: string id: type: string - name: - type: string - outboundWebhookType: - properties: - awsEventBridge: - properties: - detail: - type: string - detailType: - type: string - eventBusArn: - type: string - roleName: - type: string - source: - type: string - required: - - detail - - detailType - - eventBusArn - - roleName - - source - type: object - demisto: - properties: - payload: - type: string - url: - type: string - uuid: - type: string - required: - - payload - - url - - uuid - type: object - emailGroup: - properties: - emailAddresses: - items: - type: string - type: array - required: - - emailAddresses - type: object - genericWebhook: - properties: - headers: - additionalProperties: - type: string - type: object - method: - enum: - - Unkown - - Get - - Post - - Put - type: string - payload: - type: string - url: - type: string - uuid: - type: string - required: - - method - - url - - uuid - type: object - jira: - properties: - apiToken: - type: string - email: - type: string - projectKey: - type: string - url: - type: string - required: - - apiToken - - email - - projectKey - - url - type: object - microsoftTeams: - properties: - url: - type: string - required: - - url - type: object - opsgenie: - properties: - url: - type: string - required: - - url - type: object - pagerDuty: - properties: - serviceKey: - type: string - required: - - serviceKey - type: object - sendLog: - properties: - payload: - type: string - url: - type: string - uuid: - type: string - required: - - payload - - url - - uuid - type: object - slack: - properties: - attachments: - items: - properties: - isActive: - type: boolean - type: - type: string - required: - - isActive - - type - type: object - type: array - digests: - items: - properties: - isActive: - type: boolean - type: - type: string - required: - - isActive - - type - type: object - type: array - url: - type: string - required: - - url - type: object - type: object required: - id - - name - - outboundWebhookType type: object type: object served: true diff --git a/config/crd/bases/coralogix.com_recordingrulegroupsets.yaml b/config/crd/bases/coralogix.com_recordingrulegroupsets.yaml index 3311b0c..c68ab0b 100644 --- a/config/crd/bases/coralogix.com_recordingrulegroupsets.yaml +++ b/config/crd/bases/coralogix.com_recordingrulegroupsets.yaml @@ -78,36 +78,6 @@ spec: description: RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet properties: - groups: - items: - properties: - intervalSeconds: - default: 60 - format: int32 - type: integer - limit: - format: int64 - type: integer - name: - description: |- - INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - Important: Run "make" to regenerate code after modifying this file - type: string - rules: - items: - properties: - expr: - type: string - labels: - additionalProperties: - type: string - type: object - record: - type: string - type: object - type: array - type: object - type: array id: type: string required: diff --git a/config/crd/bases/coralogix.com_rulegroups.yaml b/config/crd/bases/coralogix.com_rulegroups.yaml index 33122cf..150e530 100644 --- a/config/crd/bases/coralogix.com_rulegroups.yaml +++ b/config/crd/bases/coralogix.com_rulegroups.yaml @@ -239,201 +239,11 @@ spec: status: description: RuleGroupStatus defines the observed state of RuleGroup properties: - active: - type: boolean - applications: - items: - type: string - type: array - creator: - type: string - description: - type: string - hidden: - type: boolean id: description: |- INSERT ADDITIONAL STATUS FIELD - define observed state of cluster Important: Run "make" to regenerate code after modifying this file type: string - name: - type: string - order: - format: int32 - type: integer - severities: - items: - enum: - - Debug - - Verbose - - Info - - Warning - - Error - - Critical - type: string - type: array - subgroups: - items: - properties: - active: - default: true - type: boolean - id: - type: string - order: - format: int32 - type: integer - rules: - items: - properties: - active: - default: true - type: boolean - block: - properties: - blockingAllMatchingBlocks: - default: true - type: boolean - keepBlockedLogs: - default: false - type: boolean - regex: - type: string - sourceField: - type: string - required: - - regex - - sourceField - type: object - description: - type: string - extract: - properties: - regex: - type: string - sourceField: - type: string - required: - - regex - - sourceField - type: object - extractTimestamp: - properties: - fieldFormatStandard: - enum: - - Strftime - - JavaSDF - - Golang - - SecondTS - - MilliTS - - MicroTS - - NanoTS - type: string - sourceField: - type: string - timeFormat: - type: string - required: - - fieldFormatStandard - - sourceField - - timeFormat - type: object - jsonExtract: - properties: - destinationField: - enum: - - Category - - CLASSNAME - - METHODNAME - - THREADID - - SEVERITY - type: string - jsonKey: - type: string - required: - - destinationField - - jsonKey - type: object - jsonStringify: - properties: - destinationField: - type: string - keepSourceField: - default: false - type: boolean - sourceField: - type: string - required: - - destinationField - - sourceField - type: object - name: - minLength: 0 - type: string - parse: - properties: - destinationField: - type: string - regex: - type: string - sourceField: - type: string - required: - - destinationField - - regex - - sourceField - type: object - parseJsonField: - properties: - destinationField: - type: string - keepDestinationField: - type: boolean - keepSourceField: - type: boolean - sourceField: - type: string - required: - - destinationField - - keepDestinationField - - keepSourceField - - sourceField - type: object - removeFields: - properties: - excludedFields: - items: - type: string - type: array - required: - - excludedFields - type: object - replace: - properties: - destinationField: - type: string - regex: - type: string - replacementString: - type: string - sourceField: - type: string - required: - - destinationField - - regex - - replacementString - - sourceField - type: object - required: - - name - type: object - type: array - type: object - type: array - subsystems: - items: - type: string - type: array required: - id type: object diff --git a/controllers/alphacontrollers/alert_controller.go b/controllers/alphacontrollers/alert_controller.go index 2e8295f..e8bd4d0 100644 --- a/controllers/alphacontrollers/alert_controller.go +++ b/controllers/alphacontrollers/alert_controller.go @@ -20,8 +20,6 @@ import ( "context" stdErr "errors" "fmt" - "time" - "github.com/go-logr/logr" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -36,8 +34,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" - cxsdk "github.com/coralogix/coralogix-management-sdk/go" - utils "github.com/coralogix/coralogix-operator/apis" coralogixv1alpha1 "github.com/coralogix/coralogix-operator/apis/coralogix/v1alpha1" "github.com/coralogix/coralogix-operator/controllers/clientset" @@ -45,16 +41,8 @@ import ( ) var ( - alertProtoSeverityToSchemaSeverity = utils.ReverseMap(coralogixv1alpha1.AlertSchemaSeverityToProtoSeverity) - alertProtoDayToSchemaDay = utils.ReverseMap(coralogixv1alpha1.AlertSchemaDayToProtoDay) - alertProtoTimeWindowToSchemaTimeWindow = utils.ReverseMap(coralogixv1alpha1.AlertSchemaTimeWindowToProtoTimeWindow) - alertProtoAutoRetireRatioToSchemaAutoRetireRatio = utils.ReverseMap(coralogixv1alpha1.AlertSchemaAutoRetireRatioToProtoAutoRetireRatio) - alertProtoFiltersLogSeverityToSchemaFiltersLogSeverity = utils.ReverseMap(coralogixv1alpha1.AlertSchemaFiltersLogSeverityToProtoFiltersLogSeverity) - alertProtoRelativeTimeFrameToSchemaTimeFrameAndRelativeTimeFrame = utils.ReverseMap(coralogixv1alpha1.AlertSchemaRelativeTimeFrameToProtoTimeFrameAndRelativeTimeFrame) - alertProtoArithmeticOperatorToSchemaArithmeticOperator = utils.ReverseMap(coralogixv1alpha1.AlertSchemaArithmeticOperatorToProtoArithmeticOperator) - alertProtoNotifyOn = utils.ReverseMap(coralogixv1alpha1.AlertSchemaNotifyOnToProtoNotifyOn) - alertProtoFlowOperatorToProtoFlowOperator = utils.ReverseMap(coralogixv1alpha1.AlertSchemaFlowOperatorToProtoFlowOperator) - alertFinalizerName = "alert.coralogix.com/finalizer" + alertProtoSeverityToSchemaSeverity = utils.ReverseMap(coralogixv1alpha1.AlertSchemaSeverityToProtoSeverity) + alertFinalizerName = "alert.coralogix.com/finalizer" ) // AlertReconciler reconciles a Alert object @@ -244,818 +232,9 @@ func getStatus(ctx context.Context, log logr.Logger, actualAlert *alerts.Alert, status.ID = utils.WrapperspbStringToStringPointer(actualAlert.GetUniqueIdentifier()) - status.Name = actualAlert.GetName().GetValue() - - status.Description = actualAlert.GetDescription().GetValue() - - status.Active = actualAlert.GetIsActive().GetValue() - - status.Severity = alertProtoSeverityToSchemaSeverity[actualAlert.GetSeverity()] - - status.Labels = flattenMetaLabels(actualAlert.GetMetaLabels()) - - status.ExpirationDate = flattenExpirationDate(actualAlert.GetExpiration()) - - var timeZone coralogixv1alpha1.TimeZone - if spec.Scheduling != nil { - timeZone = spec.Scheduling.TimeZone - } - - status.Scheduling = flattenScheduling(actualAlert.GetActiveWhen(), timeZone) - - status.AlertType = flattenAlertType(actualAlert) - - if notificationGroups, flattenErr := flattenNotificationGroups(ctx, log, actualAlert.GetNotificationGroups()); flattenErr != nil { - err = stdErr.Join(err, fmt.Errorf("error on flatten alert - %w", flattenErr)) - } else { - status.NotificationGroups = notificationGroups - } - - status.ShowInInsight = flattenShowInInsight(actualAlert.GetShowInInsight()) - - status.PayloadFilters = utils.WrappedStringSliceToStringSlice(actualAlert.GetNotificationPayloadFilters()) - return status, err } -func flattenAlertType(actualAlert *alerts.Alert) coralogixv1alpha1.AlertType { - actualFilters := actualAlert.GetFilters() - actualCondition := actualAlert.GetCondition() - - var alertType coralogixv1alpha1.AlertType - switch actualFilters.GetFilterType() { - case alerts.AlertFilters_FILTER_TYPE_TEXT_OR_UNSPECIFIED: - if newValueCondition, ok := actualCondition.GetCondition().(*alerts.AlertCondition_NewValue); ok { - alertType.NewValue = flattenNewValueAlert(actualFilters, newValueCondition) - } else { - alertType.Standard = flattenStandardAlert(actualFilters, actualCondition) - } - case alerts.AlertFilters_FILTER_TYPE_RATIO: - alertType.Ratio = flattenRatioAlert(actualFilters, actualCondition) - case alerts.AlertFilters_FILTER_TYPE_UNIQUE_COUNT: - alertType.UniqueCount = flattenUniqueCountAlert(actualFilters, actualCondition) - case alerts.AlertFilters_FILTER_TYPE_TIME_RELATIVE: - alertType.TimeRelative = flattenTimeRelativeAlert(actualFilters, actualCondition) - case alerts.AlertFilters_FILTER_TYPE_METRIC: - alertType.Metric = flattenMetricAlert(actualFilters, actualCondition) - case alerts.AlertFilters_FILTER_TYPE_TRACING: - alertType.Tracing = flattenTracingAlert(actualAlert.GetTracingAlert(), actualCondition) - case alerts.AlertFilters_FILTER_TYPE_FLOW: - alertType.Flow = flattenFlowAlert(actualCondition.GetFlow()) - } - - return alertType -} - -func flattenNewValueAlert(filters *alerts.AlertFilters, condition *alerts.AlertCondition_NewValue) *coralogixv1alpha1.NewValue { - flattenedFilters := flattenFilters(filters) - newValueCondition := flattenNewValueCondition(condition.NewValue.GetParameters()) - - newValue := &coralogixv1alpha1.NewValue{ - Filters: flattenedFilters, - Conditions: newValueCondition, - } - - return newValue -} - -func flattenFilters(filters *alerts.AlertFilters) *coralogixv1alpha1.Filters { - if filters == nil { - return nil - } - - var flattenedFilters = &coralogixv1alpha1.Filters{} - - flattenedFilters.SearchQuery = utils.WrapperspbStringToStringPointer(filters.GetText()) - - flattenedFilters.Alias = utils.WrapperspbStringToStringPointer(filters.GetAlias()) - - flattenedFilters.Severities = flattenSeverities(filters.GetSeverities()) - - if metaData := filters.Metadata; metaData != nil { - flattenedFilters.Subsystems = utils.WrappedStringSliceToStringSlice(metaData.Subsystems) - flattenedFilters.Categories = utils.WrappedStringSliceToStringSlice(metaData.Categories) - flattenedFilters.Applications = utils.WrappedStringSliceToStringSlice(metaData.Applications) - flattenedFilters.Computers = utils.WrappedStringSliceToStringSlice(metaData.Computers) - flattenedFilters.Classes = utils.WrappedStringSliceToStringSlice(metaData.Classes) - flattenedFilters.Methods = utils.WrappedStringSliceToStringSlice(metaData.Methods) - flattenedFilters.IPs = utils.WrappedStringSliceToStringSlice(metaData.IpAddresses) - } - - return flattenedFilters -} - -func flattenSeverities(severities []alerts.AlertFilters_LogSeverity) []coralogixv1alpha1.FiltersLogSeverity { - flattenedSeverities := make([]coralogixv1alpha1.FiltersLogSeverity, 0, len(severities)) - for _, severity := range severities { - sev := alertProtoFiltersLogSeverityToSchemaFiltersLogSeverity[severity] - flattenedSeverities = append(flattenedSeverities, sev) - } - return flattenedSeverities -} - -func flattenNewValueCondition(conditionParams *alerts.ConditionParameters) coralogixv1alpha1.NewValueConditions { - var key string - if actualKeys := conditionParams.GetGroupBy(); len(actualKeys) != 0 { - key = actualKeys[0].GetValue() - } - timeWindow := coralogixv1alpha1.NewValueTimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]) - - newValueCondition := coralogixv1alpha1.NewValueConditions{ - Key: key, - TimeWindow: timeWindow, - } - - return newValueCondition -} - -func flattenStandardAlert(filters *alerts.AlertFilters, condition *alerts.AlertCondition) *coralogixv1alpha1.Standard { - flattenedFilters := flattenFilters(filters) - standardCondition := flattenStandardCondition(condition) - - standard := &coralogixv1alpha1.Standard{ - Filters: flattenedFilters, - Conditions: standardCondition, - } - - return standard -} - -func flattenStandardCondition(condition *alerts.AlertCondition) coralogixv1alpha1.StandardConditions { - var standardCondition coralogixv1alpha1.StandardConditions - var conditionParams *alerts.ConditionParameters - - switch condition := condition.GetCondition().(type) { - case *alerts.AlertCondition_LessThan: - conditionParams = condition.LessThan.GetParameters() - standardCondition.AlertWhen = coralogixv1alpha1.StandardAlertWhenLessThan - standardCondition.Threshold = new(int) - standardCondition.TimeWindow = new(coralogixv1alpha1.TimeWindow) - *standardCondition.Threshold = int(conditionParams.GetThreshold().GetValue()) - *standardCondition.TimeWindow = coralogixv1alpha1.TimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]) - - if actualManageUndetectedValues := conditionParams.GetRelatedExtendedData(); actualManageUndetectedValues != nil { - actualShouldTriggerDeadman, actualCleanupDeadmanDuration := actualManageUndetectedValues.GetShouldTriggerDeadman().GetValue(), actualManageUndetectedValues.GetCleanupDeadmanDuration() - autoRetireRatio := alertProtoAutoRetireRatioToSchemaAutoRetireRatio[actualCleanupDeadmanDuration] - standardCondition.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: actualShouldTriggerDeadman, - AutoRetireRatio: &autoRetireRatio, - } - } else { - autoRetireRatio := coralogixv1alpha1.AutoRetireRatioNever - standardCondition.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: false, - AutoRetireRatio: &autoRetireRatio, - } - } - case *alerts.AlertCondition_MoreThan: - conditionParams = condition.MoreThan.GetParameters() - standardCondition.AlertWhen = coralogixv1alpha1.StandardAlertWhenMoreThan - standardCondition.Threshold = new(int) - standardCondition.TimeWindow = new(coralogixv1alpha1.TimeWindow) - *standardCondition.Threshold = int(conditionParams.GetThreshold().GetValue()) - *standardCondition.TimeWindow = coralogixv1alpha1.TimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]) - case *alerts.AlertCondition_MoreThanUsual: - conditionParams = condition.MoreThanUsual.GetParameters() - standardCondition.AlertWhen = coralogixv1alpha1.StandardAlertWhenMoreThanUsual - standardCondition.Threshold = new(int) - *standardCondition.Threshold = int(conditionParams.GetThreshold().GetValue()) - case *alerts.AlertCondition_Immediate: - standardCondition.AlertWhen = coralogixv1alpha1.StandardAlertWhenImmediately - return standardCondition - } - - standardCondition.GroupBy = utils.WrappedStringSliceToStringSlice(conditionParams.GetGroupBy()) - - return standardCondition -} - -func flattenRatioAlert(filters *alerts.AlertFilters, condition *alerts.AlertCondition) *coralogixv1alpha1.Ratio { - query1Filters := flattenFilters(filters) - q2Filters := filters.GetRatioAlerts()[0] - query2Filters := flattenRatioFilters(q2Filters) - ratioCondition := flattenRatioCondition(condition, q2Filters.GetGroupBy()) - - ratio := &coralogixv1alpha1.Ratio{ - Query1Filters: *query1Filters, - Query2Filters: query2Filters, - Conditions: ratioCondition, - } - - return ratio -} - -func flattenRatioFilters(filters *alerts.AlertFilters_RatioAlert) coralogixv1alpha1.RatioQ2Filters { - var flattenedFilters coralogixv1alpha1.RatioQ2Filters - if filters == nil { - return flattenedFilters - } - - flattenedFilters.SearchQuery = utils.WrapperspbStringToStringPointer(filters.GetText()) - - flattenedFilters.Alias = utils.WrapperspbStringToStringPointer(filters.GetAlias()) - - flattenedFilters.Severities = flattenSeverities(filters.GetSeverities()) - flattenedFilters.Subsystems = utils.WrappedStringSliceToStringSlice(filters.GetSubsystems()) - flattenedFilters.Applications = utils.WrappedStringSliceToStringSlice(filters.GetApplications()) - - return flattenedFilters -} - -func flattenRatioCondition(condition *alerts.AlertCondition, groupByQ2 []*wrapperspb.StringValue) coralogixv1alpha1.RatioConditions { - var ratioCondition coralogixv1alpha1.RatioConditions - var conditionParams *alerts.ConditionParameters - - switch condition := condition.GetCondition().(type) { - case *alerts.AlertCondition_LessThan: - conditionParams = condition.LessThan.GetParameters() - ratioCondition.AlertWhen = coralogixv1alpha1.AlertWhenLessThan - - if actualManageUndetectedValues := conditionParams.GetRelatedExtendedData(); actualManageUndetectedValues != nil { - actualShouldTriggerDeadman, actualCleanupDeadmanDuration := actualManageUndetectedValues.GetShouldTriggerDeadman().GetValue(), actualManageUndetectedValues.GetCleanupDeadmanDuration() - autoRetireRatio := alertProtoAutoRetireRatioToSchemaAutoRetireRatio[actualCleanupDeadmanDuration] - ratioCondition.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: actualShouldTriggerDeadman, - AutoRetireRatio: &autoRetireRatio, - } - } else { - autoRetireRatio := coralogixv1alpha1.AutoRetireRatioNever - ratioCondition.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: false, - AutoRetireRatio: &autoRetireRatio, - } - } - case *alerts.AlertCondition_MoreThan: - conditionParams = condition.MoreThan.GetParameters() - ratioCondition.AlertWhen = coralogixv1alpha1.AlertWhenMoreThan - } - - ratioCondition.Ratio = utils.FloatToQuantity(conditionParams.GetThreshold().GetValue()) - ratioCondition.TimeWindow = coralogixv1alpha1.TimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]) - - if groupByQ1 := conditionParams.GetGroupBy(); len(groupByQ1) > 0 && len(groupByQ2) == 0 { - ratioCondition.GroupBy = utils.WrappedStringSliceToStringSlice(groupByQ1) - ratioCondition.GroupByFor = new(coralogixv1alpha1.GroupByFor) - *ratioCondition.GroupByFor = coralogixv1alpha1.GroupByForQ1 - } else if len(groupByQ2) > 0 && len(groupByQ1) == 0 { - ratioCondition.GroupBy = utils.WrappedStringSliceToStringSlice(groupByQ2) - ratioCondition.GroupByFor = new(coralogixv1alpha1.GroupByFor) - *ratioCondition.GroupByFor = coralogixv1alpha1.GroupByForQ2 - } else if len(groupByQ1) > 0 && len(groupByQ2) > 0 { - ratioCondition.GroupBy = utils.WrappedStringSliceToStringSlice(groupByQ2) - ratioCondition.GroupByFor = new(coralogixv1alpha1.GroupByFor) - *ratioCondition.GroupByFor = coralogixv1alpha1.GroupByForBoth - } - - return ratioCondition -} - -func flattenUniqueCountAlert(filters *alerts.AlertFilters, condition *alerts.AlertCondition) *coralogixv1alpha1.UniqueCount { - flattenedFilters := flattenFilters(filters) - uniqueCountCondition := flattenUniqueCountCondition(condition) - - ratio := &coralogixv1alpha1.UniqueCount{ - Filters: flattenedFilters, - Conditions: uniqueCountCondition, - } - - return ratio -} - -func flattenUniqueCountCondition(condition *alerts.AlertCondition) coralogixv1alpha1.UniqueCountConditions { - conditionParams := condition.GetCondition().(*alerts.AlertCondition_UniqueCount).UniqueCount.GetParameters() - var uniqueCountCondition coralogixv1alpha1.UniqueCountConditions - - uniqueCountCondition.Key = conditionParams.GetCardinalityFields()[0].GetValue() - uniqueCountCondition.MaxUniqueValues = int(conditionParams.GetThreshold().GetValue()) - uniqueCountCondition.TimeWindow = coralogixv1alpha1.UniqueValueTimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]) - if actualGroupBy := conditionParams.GetGroupBy(); len(actualGroupBy) > 0 { - uniqueCountCondition.GroupBy = new(string) - *uniqueCountCondition.GroupBy = actualGroupBy[0].GetValue() - - uniqueCountCondition.MaxUniqueValuesForGroupBy = new(int) - *uniqueCountCondition.MaxUniqueValuesForGroupBy = int(conditionParams.GetMaxUniqueCountValuesForGroupByKey().GetValue()) - } - - return uniqueCountCondition -} - -func flattenTimeRelativeAlert(filters *alerts.AlertFilters, condition *alerts.AlertCondition) *coralogixv1alpha1.TimeRelative { - flattenedFilters := flattenFilters(filters) - timeRelativeCondition := flattenTimeRelativeCondition(condition) - - timeRelative := &coralogixv1alpha1.TimeRelative{ - Filters: flattenedFilters, - Conditions: timeRelativeCondition, - } - - return timeRelative -} - -func flattenTimeRelativeCondition(condition *alerts.AlertCondition) coralogixv1alpha1.TimeRelativeConditions { - var conditionParams *alerts.ConditionParameters - var timeRelativeCondition coralogixv1alpha1.TimeRelativeConditions - - switch condition := condition.GetCondition().(type) { - case *alerts.AlertCondition_LessThan: - conditionParams = condition.LessThan.GetParameters() - timeRelativeCondition.AlertWhen = coralogixv1alpha1.AlertWhenLessThan - - if actualManageUndetectedValues := conditionParams.GetRelatedExtendedData(); actualManageUndetectedValues != nil { - actualShouldTriggerDeadman, actualCleanupDeadmanDuration := actualManageUndetectedValues.GetShouldTriggerDeadman().GetValue(), actualManageUndetectedValues.GetCleanupDeadmanDuration() - autoRetireRatio := alertProtoAutoRetireRatioToSchemaAutoRetireRatio[actualCleanupDeadmanDuration] - timeRelativeCondition.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: actualShouldTriggerDeadman, - AutoRetireRatio: &autoRetireRatio, - } - } else { - autoRetireRatio := coralogixv1alpha1.AutoRetireRatioNever - timeRelativeCondition.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: false, - AutoRetireRatio: &autoRetireRatio, - } - } - case *alerts.AlertCondition_MoreThan: - conditionParams = condition.MoreThan.GetParameters() - timeRelativeCondition.AlertWhen = coralogixv1alpha1.AlertWhenMoreThan - } - - timeRelativeCondition.Threshold = utils.FloatToQuantity(conditionParams.GetThreshold().GetValue()) - relativeTimeFrame := coralogixv1alpha1.ProtoTimeFrameAndRelativeTimeFrame{TimeFrame: conditionParams.GetTimeframe(), RelativeTimeFrame: conditionParams.GetRelativeTimeframe()} - timeRelativeCondition.TimeWindow = alertProtoRelativeTimeFrameToSchemaTimeFrameAndRelativeTimeFrame[relativeTimeFrame] - timeRelativeCondition.IgnoreInfinity = conditionParams.GetIgnoreInfinity().GetValue() - timeRelativeCondition.GroupBy = utils.WrappedStringSliceToStringSlice(conditionParams.GetGroupBy()) - - return timeRelativeCondition -} - -func flattenMetricAlert(filters *alerts.AlertFilters, condition *alerts.AlertCondition) *coralogixv1alpha1.Metric { - metric := new(coralogixv1alpha1.Metric) - - var conditionParams *alerts.ConditionParameters - var promqlAlertWhen coralogixv1alpha1.PromqlAlertWhen - var luceneAlertWhen coralogixv1alpha1.AlertWhen - switch condition := condition.GetCondition().(type) { - case *alerts.AlertCondition_LessThan: - promqlAlertWhen = coralogixv1alpha1.PromqlAlertWhenLessThan - luceneAlertWhen = coralogixv1alpha1.AlertWhenLessThan - conditionParams = condition.LessThan.GetParameters() - case *alerts.AlertCondition_MoreThan: - conditionParams = condition.MoreThan.GetParameters() - promqlAlertWhen = coralogixv1alpha1.PromqlAlertWhenMoreThan - luceneAlertWhen = coralogixv1alpha1.AlertWhenMoreThan - case *alerts.AlertCondition_MoreThanUsual: - conditionParams = condition.MoreThanUsual.GetParameters() - promqlAlertWhen = coralogixv1alpha1.PromqlAlertWhenMoreThanUsual - } - - if promqlParams := conditionParams.GetMetricAlertPromqlParameters(); promqlParams != nil { - metric.Promql = flattenPromqlAlert(conditionParams, promqlParams, promqlAlertWhen) - } else { - metric.Lucene = flattenLuceneAlert(conditionParams, filters.GetText(), luceneAlertWhen) - } - - return metric -} - -func flattenPromqlAlert(conditionParams *alerts.ConditionParameters, promqlParams *alerts.MetricAlertPromqlConditionParameters, alertWhen coralogixv1alpha1.PromqlAlertWhen) *coralogixv1alpha1.Promql { - promql := new(coralogixv1alpha1.Promql) - - promql.SearchQuery = promqlParams.GetPromqlText().GetValue() - promql.Conditions = coralogixv1alpha1.PromqlConditions{ - AlertWhen: alertWhen, - Threshold: utils.FloatToQuantity(conditionParams.GetThreshold().GetValue()), - SampleThresholdPercentage: int(promqlParams.GetSampleThresholdPercentage().GetValue()), - TimeWindow: coralogixv1alpha1.MetricTimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]), - ReplaceMissingValueWithZero: promqlParams.GetSwapNullValues().GetValue(), - } - - if minNonNullValuesPercentage := promqlParams.GetNonNullPercentage(); minNonNullValuesPercentage != nil { - promql.Conditions.MinNonNullValuesPercentage = new(int) - *promql.Conditions.MinNonNullValuesPercentage = int(minNonNullValuesPercentage.GetValue()) - } - - if alertWhen == coralogixv1alpha1.PromqlAlertWhenLessThan { - if actualManageUndetectedValues := conditionParams.GetRelatedExtendedData(); actualManageUndetectedValues != nil { - actualShouldTriggerDeadman, actualCleanupDeadmanDuration := actualManageUndetectedValues.GetShouldTriggerDeadman().GetValue(), actualManageUndetectedValues.GetCleanupDeadmanDuration() - autoRetireRatio := alertProtoAutoRetireRatioToSchemaAutoRetireRatio[actualCleanupDeadmanDuration] - promql.Conditions.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: actualShouldTriggerDeadman, - AutoRetireRatio: &autoRetireRatio, - } - } else { - autoRetireRatio := coralogixv1alpha1.AutoRetireRatioNever - promql.Conditions.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: false, - AutoRetireRatio: &autoRetireRatio, - } - } - } - - return promql -} - -func flattenLuceneAlert(conditionParams *alerts.ConditionParameters, searchQuery *wrapperspb.StringValue, alertWhen coralogixv1alpha1.AlertWhen) *coralogixv1alpha1.Lucene { - lucene := new(coralogixv1alpha1.Lucene) - metricParams := conditionParams.GetMetricAlertParameters() - - if searchQuery != nil { - lucene.SearchQuery = new(string) - *lucene.SearchQuery = searchQuery.GetValue() - } - - lucene.Conditions = coralogixv1alpha1.LuceneConditions{ - MetricField: metricParams.GetMetricField().GetValue(), - ArithmeticOperator: alertProtoArithmeticOperatorToSchemaArithmeticOperator[metricParams.GetArithmeticOperator()], - AlertWhen: alertWhen, - Threshold: utils.FloatToQuantity(conditionParams.GetThreshold().GetValue()), - SampleThresholdPercentage: int(metricParams.GetSampleThresholdPercentage().GetValue()), - TimeWindow: coralogixv1alpha1.MetricTimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]), - GroupBy: utils.WrappedStringSliceToStringSlice(conditionParams.GetGroupBy()), - ReplaceMissingValueWithZero: metricParams.GetSwapNullValues().GetValue(), - MinNonNullValuesPercentage: int(metricParams.GetNonNullPercentage().GetValue()), - } - - if arithmeticOperatorModifier := metricParams.GetArithmeticOperatorModifier(); arithmeticOperatorModifier != nil { - lucene.Conditions.ArithmeticOperatorModifier = new(int) - *lucene.Conditions.ArithmeticOperatorModifier = int(arithmeticOperatorModifier.GetValue()) - } - - if alertWhen == coralogixv1alpha1.AlertWhenLessThan { - if actualManageUndetectedValues := conditionParams.GetRelatedExtendedData(); actualManageUndetectedValues != nil { - actualShouldTriggerDeadman, actualCleanupDeadmanDuration := actualManageUndetectedValues.GetShouldTriggerDeadman().GetValue(), actualManageUndetectedValues.GetCleanupDeadmanDuration() - autoRetireRatio := alertProtoAutoRetireRatioToSchemaAutoRetireRatio[actualCleanupDeadmanDuration] - lucene.Conditions.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: actualShouldTriggerDeadman, - AutoRetireRatio: &autoRetireRatio, - } - } else { - autoRetireRatio := coralogixv1alpha1.AutoRetireRatioNever - lucene.Conditions.ManageUndetectedValues = &coralogixv1alpha1.ManageUndetectedValues{ - EnableTriggeringOnUndetectedValues: false, - AutoRetireRatio: &autoRetireRatio, - } - } - } - - return lucene -} - -func flattenTracingAlert(tracingAlert *alerts.TracingAlert, condition *alerts.AlertCondition) *coralogixv1alpha1.Tracing { - latencyThresholdMS := float64(tracingAlert.GetConditionLatency()) / float64(time.Millisecond.Microseconds()) - tracingFilters := flattenTracingAlertFilters(tracingAlert) - tracingFilters.LatencyThresholdMilliseconds = utils.FloatToQuantity(latencyThresholdMS) - - tracingCondition := flattenTracingCondition(condition) - - return &coralogixv1alpha1.Tracing{ - Filters: tracingFilters, - Conditions: tracingCondition, - } -} - -func flattenTracingCondition(condition *alerts.AlertCondition) coralogixv1alpha1.TracingCondition { - var tracingCondition coralogixv1alpha1.TracingCondition - switch condition := condition.GetCondition().(type) { - case *alerts.AlertCondition_Immediate: - tracingCondition.AlertWhen = coralogixv1alpha1.TracingAlertWhenImmediately - case *alerts.AlertCondition_MoreThan: - conditionParams := condition.MoreThan.GetParameters() - tracingCondition.AlertWhen = coralogixv1alpha1.TracingAlertWhenMore - - tracingCondition.Threshold = new(int) - *tracingCondition.Threshold = int(conditionParams.GetThreshold().GetValue()) - - tracingCondition.TimeWindow = new(coralogixv1alpha1.TimeWindow) - *tracingCondition.TimeWindow = coralogixv1alpha1.TimeWindow(alertProtoTimeWindowToSchemaTimeWindow[conditionParams.GetTimeframe()]) - - tracingCondition.GroupBy = utils.WrappedStringSliceToStringSlice(conditionParams.GetGroupBy()) - } - - return tracingCondition -} - -func flattenTracingAlertFilters(tracingAlert *alerts.TracingAlert) coralogixv1alpha1.TracingFilters { - applications, subsystems, services := flattenTracingFilters(tracingAlert.GetFieldFilters()) - tagFilters := flattenTagFiltersData(tracingAlert.GetTagFilters()) - - return coralogixv1alpha1.TracingFilters{ - TagFilters: tagFilters, - Applications: applications, - Subsystems: subsystems, - Services: services, - } -} - -func flattenTracingFilters(tracingFilters []*alerts.FilterData) (applications, subsystems, services []string) { - filtersData := flattenFiltersData(tracingFilters) - applications = filtersData["applicationName"] - subsystems = filtersData["subsystemName"] - services = filtersData["serviceName"] - return -} - -func flattenTagFiltersData(filtersData []*alerts.FilterData) []coralogixv1alpha1.TagFilter { - fieldToFilters := flattenFiltersData(filtersData) - result := make([]coralogixv1alpha1.TagFilter, 0, len(fieldToFilters)) - for field, filters := range fieldToFilters { - filterSchema := coralogixv1alpha1.TagFilter{ - Field: field, - Values: filters, - } - result = append(result, filterSchema) - } - return result -} - -func flattenFiltersData(filtersData []*alerts.FilterData) map[string][]string { - result := make(map[string][]string, len(filtersData)) - for _, filter := range filtersData { - field := filter.GetField() - result[field] = flattenTracingFilter(filter.GetFilters()) - } - return result -} - -func flattenTracingFilter(filters []*alerts.Filters) []string { - result := make([]string, 0) - for _, f := range filters { - values := f.GetValues() - switch operator := f.GetOperator(); operator { - case "notEquals", "contains", "startsWith", "endsWith": - for i, val := range values { - values[i] = fmt.Sprintf("filter:%s:%s", operator, val) - } - } - result = append(result, values...) - } - return result -} - -func flattenFlowAlert(flow *alerts.FlowCondition) *coralogixv1alpha1.Flow { - stages := flattenFlowStages(flow.Stages) - return &coralogixv1alpha1.Flow{ - Stages: stages, - } -} - -func flattenFlowStages(stages []*alerts.FlowStage) []coralogixv1alpha1.FlowStage { - result := make([]coralogixv1alpha1.FlowStage, 0, len(stages)) - for _, s := range stages { - stage := flattenFlowStage(s) - result = append(result, stage) - } - return result -} - -func flattenFlowStage(stage *alerts.FlowStage) coralogixv1alpha1.FlowStage { - groups := flattenFlowStageGroups(stage.Groups) - - var timeFrame *coralogixv1alpha1.FlowStageTimeFrame - if timeWindow := stage.GetTimeframe(); timeWindow != nil { - timeFrame = convertMillisecondToTime(int(timeWindow.GetMs().GetValue())) - } - - return coralogixv1alpha1.FlowStage{ - Groups: groups, - TimeWindow: timeFrame, - } -} - -func convertMillisecondToTime(timeMS int) *coralogixv1alpha1.FlowStageTimeFrame { - if timeMS == 0 { - return nil - } - - msInHour := int(time.Hour.Milliseconds()) - msInMinute := int(time.Minute.Milliseconds()) - msInSecond := int(time.Second.Milliseconds()) - - hours := timeMS / msInHour - timeMS -= hours * msInHour - - minutes := timeMS / msInMinute - timeMS -= minutes * msInMinute - - seconds := timeMS / msInSecond - - return &coralogixv1alpha1.FlowStageTimeFrame{ - Hours: hours, - Minutes: minutes, - Seconds: seconds, - } -} - -func flattenFlowStageGroups(groups []*alerts.FlowGroup) []coralogixv1alpha1.FlowStageGroup { - result := make([]coralogixv1alpha1.FlowStageGroup, 0, len(groups)) - for _, g := range groups { - group := flattenFlowStageGroup(g) - result = append(result, group) - } - return result -} - -func flattenFlowStageGroup(group *alerts.FlowGroup) coralogixv1alpha1.FlowStageGroup { - subAlerts := expandFlowSubgroupAlerts(group.GetAlerts()) - nextOp := alertProtoFlowOperatorToProtoFlowOperator[group.GetNextOp()] - return coralogixv1alpha1.FlowStageGroup{ - InnerFlowAlerts: subAlerts, - NextOperator: nextOp, - } -} - -func expandFlowSubgroupAlerts(subgroup *alerts.FlowAlerts) coralogixv1alpha1.InnerFlowAlerts { - return coralogixv1alpha1.InnerFlowAlerts{ - Operator: alertProtoFlowOperatorToProtoFlowOperator[subgroup.GetOp()], - Alerts: expandFlowInnerAlerts(subgroup.GetValues()), - } -} - -func expandFlowInnerAlerts(innerAlerts []*alerts.FlowAlert) []coralogixv1alpha1.InnerFlowAlert { - result := make([]coralogixv1alpha1.InnerFlowAlert, 0, len(innerAlerts)) - for _, a := range innerAlerts { - alert := expandFlowInnerAlert(a) - result = append(result, alert) - } - return result -} - -func expandFlowInnerAlert(alert *alerts.FlowAlert) coralogixv1alpha1.InnerFlowAlert { - return coralogixv1alpha1.InnerFlowAlert{ - UserAlertId: alert.GetId().GetValue(), - Not: alert.GetNot().GetValue(), - } -} - -func flattenMetaLabels(labels []*alerts.MetaLabel) map[string]string { - if len(labels) == 0 { - return nil - } - - result := make(map[string]string) - for _, label := range labels { - result[label.GetKey().GetValue()] = label.GetValue().GetValue() - } - return result -} - -func flattenExpirationDate(expirationDate *alerts.Date) *coralogixv1alpha1.ExpirationDate { - if expirationDate == nil { - return nil - } - - return &coralogixv1alpha1.ExpirationDate{ - Day: expirationDate.Day, - Month: expirationDate.Month, - Year: expirationDate.Year, - } -} - -func flattenScheduling(scheduling *alerts.AlertActiveWhen, timeZone coralogixv1alpha1.TimeZone) *coralogixv1alpha1.Scheduling { - if scheduling == nil || len(scheduling.GetTimeframes()) == 0 { - return nil - } - - utc := coralogixv1alpha1.ExtractUTC(timeZone) - timeframe := scheduling.GetTimeframes()[0] - timeRange := timeframe.GetRange() - activityStartGMT, activityEndGMT := timeRange.GetStart(), timeRange.GetEnd() - daysOffset := getDaysOffsetFromGMT(activityStartGMT, utc) - daysEnabled := flattenDaysOfWeek(timeframe.GetDaysOfWeek(), daysOffset) - activityStartUTC := flattenTimeInDay(activityStartGMT, utc) - activityEndUTC := flattenTimeInDay(activityEndGMT, utc) - - return &coralogixv1alpha1.Scheduling{ - TimeZone: timeZone, - DaysEnabled: daysEnabled, - StartTime: activityStartUTC, - EndTime: activityEndUTC, - } -} - -func getDaysOffsetFromGMT(activityStartGMT *alerts.Time, utc int32) int32 { - daysOffset := int32(activityStartGMT.GetHours()+utc) / 24 - if daysOffset < 0 { - daysOffset += 7 - } - - return daysOffset -} - -func flattenTimeInDay(time *alerts.Time, utc int32) *coralogixv1alpha1.Time { - hours := convertGmtToUtc(time.GetHours(), utc) - hoursStr := toTwoDigitsFormat(hours) - minStr := toTwoDigitsFormat(time.GetMinutes()) - result := coralogixv1alpha1.Time(fmt.Sprintf("%s:%s", hoursStr, minStr)) - return &result -} - -func convertGmtToUtc(hours, utc int32) int32 { - hours += utc - if hours < 0 { - hours += 24 - } else if hours >= 24 { - hours -= 24 - } - - return hours -} - -func toTwoDigitsFormat(digit int32) string { - digitStr := fmt.Sprintf("%d", digit) - if len(digitStr) == 1 { - digitStr = "0" + digitStr - } - return digitStr -} - -func flattenDaysOfWeek(daysOfWeek []alerts.DayOfWeek, daysOffset int32) []coralogixv1alpha1.Day { - result := make([]coralogixv1alpha1.Day, 0, len(daysOfWeek)) - for _, d := range daysOfWeek { - dayConvertedFromGmtToUtc := alerts.DayOfWeek((int32(d) + daysOffset) % 7) - day := alertProtoDayToSchemaDay[dayConvertedFromGmtToUtc] - result = append(result, day) - } - return result -} - -func flattenNotificationGroups(ctx context.Context, log logr.Logger, notificationGroups []*alerts.AlertNotificationGroups) ([]coralogixv1alpha1.NotificationGroup, error) { - result := make([]coralogixv1alpha1.NotificationGroup, 0, len(notificationGroups)) - webhooksIdsToNames, err := getWebhooksIdsToNames(ctx, log) - if err != nil { - return nil, fmt.Errorf("error on get webhooks ids to names - %w", err) - } - - for _, ng := range notificationGroups { - notificationGroup := flattenNotificationGroup(ng, webhooksIdsToNames) - result = append(result, *notificationGroup) - } - - return result, err -} - -func getWebhooksIdsToNames(ctx context.Context, log logr.Logger) (map[uint32]string, error) { - log.V(1).Info("get all webhooks") - webhooks, err := coralogixv1alpha1.WebhooksClient.List(ctx, &cxsdk.ListAllOutgoingWebhooksRequest{}) - if err != nil { - return nil, fmt.Errorf("error on get all webhooks - %w", err) - } - webhooksIdsToNames := make(map[uint32]string) - for _, webhook := range webhooks.Deployed { - webhooksIdsToNames[webhook.GetExternalId().GetValue()] = webhook.GetName().GetValue() - } - return webhooksIdsToNames, nil -} - -func flattenNotificationGroup(notificationGroup *alerts.AlertNotificationGroups, webhooksIdsToNames map[uint32]string) *coralogixv1alpha1.NotificationGroup { - return &coralogixv1alpha1.NotificationGroup{ - GroupByFields: utils.WrappedStringSliceToStringSlice(notificationGroup.GroupByFields), - Notifications: flattenNotifications(notificationGroup.Notifications, webhooksIdsToNames), - } -} - -func flattenNotifications(notifications []*alerts.AlertNotification, webhooksIdsToNames map[uint32]string) []coralogixv1alpha1.Notification { - result := make([]coralogixv1alpha1.Notification, 0, len(notifications)) - for _, notification := range notifications { - flattenedNotification := flattenNotification(notification, webhooksIdsToNames) - result = append(result, flattenedNotification) - } - return result -} - -func flattenNotification(notification *alerts.AlertNotification, webhooksIdsToNames map[uint32]string) coralogixv1alpha1.Notification { - notifyOn := alertProtoNotifyOn[notification.GetNotifyOn()] - retriggeringPeriodMinutes := int32(notification.GetRetriggeringPeriodSeconds().GetValue()) / 60 - flattenedNotification := coralogixv1alpha1.Notification{ - NotifyOn: notifyOn, - RetriggeringPeriodMinutes: retriggeringPeriodMinutes, - } - - switch integration := notification.GetIntegrationType().(type) { - case *alerts.AlertNotification_IntegrationId: - webhookName, _ := webhooksIdsToNames[integration.IntegrationId.GetValue()] - flattenedNotification.IntegrationName = pointer.String(webhookName) - case *alerts.AlertNotification_Recipients: - flattenedNotification.EmailRecipients = utils.WrappedStringSliceToStringSlice(integration.Recipients.Emails) - } - - return flattenedNotification -} - -func flattenShowInInsight(showInInsight *alerts.ShowInInsight) *coralogixv1alpha1.ShowInInsight { - if showInInsight == nil { - return nil - } - - retriggeringPeriodMinutes := int32(showInInsight.GetRetriggeringPeriodSeconds().GetValue()) / 60 - notifyOn := alertProtoNotifyOn[showInInsight.GetNotifyOn()] - - return &coralogixv1alpha1.ShowInInsight{ - RetriggeringPeriodMinutes: retriggeringPeriodMinutes, - NotifyOn: notifyOn, - } -} - // SetupWithManager sets up the controller with the Manager. func (r *AlertReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). diff --git a/controllers/alphacontrollers/alert_controller_test.go b/controllers/alphacontrollers/alert_controller_test.go index aaed4a5..a36c1ff 100644 --- a/controllers/alphacontrollers/alert_controller_test.go +++ b/controllers/alphacontrollers/alert_controller_test.go @@ -336,11 +336,7 @@ func TestAlertUpdate(t *testing.T) { AlertType: defaultAlertType, }, Status: coralogixv1alpha1.AlertStatus{ - ID: pointer.String("AlertUpdateSuccess"), - Name: "AlertUpdateSuccess", - Description: "AlertUpdateSuccess", - Active: true, - Severity: "Critical", + ID: pointer.String("AlertUpdateSuccess"), }, }, remoteAlert: &alerts.Alert{ @@ -404,11 +400,7 @@ func TestAlertUpdate(t *testing.T) { AlertType: defaultAlertType, }, Status: coralogixv1alpha1.AlertStatus{ - ID: pointer.String("AlertUpdateCleanStatus"), - Name: "AlertUpdateCleanStatus", - Description: "AlertUpdateCleanStatus", - Active: true, - Severity: "Critical", + ID: pointer.String("AlertUpdateCleanStatus"), }, }, remoteAlert: &alerts.Alert{ @@ -618,11 +610,7 @@ func TestAlertDelete(t *testing.T) { AlertType: defaultAlertType, }, Status: coralogixv1alpha1.AlertStatus{ - ID: pointer.String("AlertDeleteSuccess"), - Name: "AlertDeleteSuccess", - Description: "AlertDeleteSuccess", - Active: true, - Severity: "Critical", + ID: pointer.String("AlertDeleteSuccess"), }, }, remoteAlert: &alerts.Alert{ @@ -793,28 +781,7 @@ func TestFlattenAlerts(t *testing.T) { assert.NoError(t, err) expected := &coralogixv1alpha1.AlertStatus{ - ID: pointer.String("id1"), - Name: "name", - Description: "description", - Active: true, - Severity: "Critical", - Labels: map[string]string{"key": "value"}, - AlertType: coralogixv1alpha1.AlertType{ - Metric: &coralogixv1alpha1.Metric{ - Promql: &coralogixv1alpha1.Promql{ - SearchQuery: "http_requests_total{status!~\"4..\"}", - Conditions: coralogixv1alpha1.PromqlConditions{ - AlertWhen: "MoreThanUsual", - Threshold: utils.FloatToQuantity(3.0), - TimeWindow: coralogixv1alpha1.MetricTimeWindow("TwelveHours"), - MinNonNullValuesPercentage: pointer.Int(10), - ReplaceMissingValueWithZero: false, - }, - }, - }, - }, - NotificationGroups: []coralogixv1alpha1.NotificationGroup{}, - PayloadFilters: []string{}, + ID: pointer.String("id1"), } assert.EqualValues(t, expected, &status) diff --git a/controllers/alphacontrollers/outboundwebhook_controller.go b/controllers/alphacontrollers/outboundwebhook_controller.go index 44905b3..d7fc607 100644 --- a/controllers/alphacontrollers/outboundwebhook_controller.go +++ b/controllers/alphacontrollers/outboundwebhook_controller.go @@ -127,9 +127,7 @@ func (r *OutboundWebhookReconciler) create(ctx context.Context, log logr.Logger, log.V(int(zapcore.DebugLevel)).Info(fmt.Sprintf("outbound-webhook was created- %s", protojson.Format(createResponse))) webhook.Status = coralogixv1alpha1.OutboundWebhookStatus{ - ID: ptr.To(createResponse.Id.GetValue()), - Name: webhook.Name, - OutboundWebhookType: &coralogixv1alpha1.OutboundWebhookTypeStatus{}, + ID: ptr.To(createResponse.Id.GetValue()), } if err = r.Status().Update(ctx, webhook); err != nil { return fmt.Errorf("error to update outbound-webhook status -\n%v", webhook) @@ -168,194 +166,14 @@ func getOutboundWebhookStatus(webhook *cxsdk.OutgoingWebhook) (*coralogixv1alpha return nil, fmt.Errorf("outbound-webhook is nil") } - outboundWebhookType, err := getOutboundWebhookTypeStatus(webhook) - if err != nil { - return nil, err - } - status := &coralogixv1alpha1.OutboundWebhookStatus{ - ID: ptr.To(webhook.Id.GetValue()), - ExternalID: ptr.To(strconv.Itoa(int(webhook.ExternalId.GetValue()))), - Name: webhook.Name.GetValue(), - OutboundWebhookType: outboundWebhookType, + ID: ptr.To(webhook.Id.GetValue()), + ExternalID: ptr.To(strconv.Itoa(int(webhook.ExternalId.GetValue()))), } return status, nil } -func getOutboundWebhookTypeStatus(webhook *cxsdk.OutgoingWebhook) (*coralogixv1alpha1.OutboundWebhookTypeStatus, error) { - if webhook == nil { - return nil, fmt.Errorf("outbound-webhook is nil") - } - - outboundWebhooks := &coralogixv1alpha1.OutboundWebhookTypeStatus{} - switch webhookType := webhook.Config.(type) { - case *cxsdk.GenericWebhook: - outboundWebhooks.GenericWebhook = getOutboundWebhookGenericTypeStatus(webhookType.GenericWebhook, webhook.Url) - case *cxsdk.SlackWebhook: - outboundWebhooks.Slack = getOutgoingWebhookSlackStatus(webhookType.Slack, webhook.Url) - case *cxsdk.PagerDutyWebhook: - outboundWebhooks.PagerDuty = getOutgoingWebhookPagerDutyStatus(webhookType.PagerDuty) - case *cxsdk.SendLogWebhook: - outboundWebhooks.SendLog = getOutgoingWebhookSendLogStatus(webhookType.SendLog, webhook.Url) - case *cxsdk.EmailGroupWebhook: - outboundWebhooks.EmailGroup = getOutgoingWebhookEmailGroupStatus(webhookType.EmailGroup) - case *cxsdk.MicrosoftTeamsWebhook: - outboundWebhooks.MicrosoftTeams = getOutgoingWebhookMicrosoftTeamsStatus(webhookType.MicrosoftTeams, webhook.Url) - case *cxsdk.JiraWebhook: - outboundWebhooks.Jira = getOutboundWebhookJiraStatus(webhookType.Jira, webhook.Url) - case *cxsdk.OpsgenieWebhook: - outboundWebhooks.Opsgenie = getOutboundWebhookOpsgenieStatus(webhookType.Opsgenie, webhook.Url) - case *cxsdk.DemistoWebhook: - outboundWebhooks.Demisto = getOutboundWebhookDemistoStatus(webhookType.Demisto, webhook.Url) - case *cxsdk.AwsEventBridgeWebhook: - outboundWebhooks.AwsEventBridge = getOutboundWebhookAwsEventBridgeStatus(webhookType.AwsEventBridge) - default: - return nil, fmt.Errorf("unsupported outbound-webhook type %T", webhookType) - } - - return outboundWebhooks, nil -} - -func getOutboundWebhookAwsEventBridgeStatus(awsEventBridge *cxsdk.AwsEventBridgeConfig) *coralogixv1alpha1.AwsEventBridge { - if awsEventBridge == nil { - return nil - } - - return &coralogixv1alpha1.AwsEventBridge{ - EventBusArn: awsEventBridge.EventBusArn.GetValue(), - Detail: awsEventBridge.Detail.GetValue(), - DetailType: awsEventBridge.DetailType.GetValue(), - Source: awsEventBridge.Source.GetValue(), - RoleName: awsEventBridge.RoleName.GetValue(), - } -} - -func getOutboundWebhookGenericTypeStatus(generic *cxsdk.GenericWebhookConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.GenericWebhookStatus { - if generic == nil { - return nil - } - - return &coralogixv1alpha1.GenericWebhookStatus{ - Uuid: generic.Uuid.GetValue(), - Url: url.GetValue(), - Method: coralogixv1alpha1.GenericWebhookMethodTypeFromProto[generic.Method], - Headers: generic.Headers, - Payload: utils.WrapperspbStringToStringPointer(generic.Payload), - } -} - -func getOutgoingWebhookSlackStatus(slack *cxsdk.SlackConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.Slack { - if slack == nil { - return nil - } - - return &coralogixv1alpha1.Slack{ - Url: url.GetValue(), - Digests: flattenSlackDigests(slack.Digests), - Attachments: flattenSlackConfigAttachments(slack.Attachments), - } -} - -func getOutgoingWebhookPagerDutyStatus(pagerDuty *cxsdk.PagerDutyConfig) *coralogixv1alpha1.PagerDuty { - if pagerDuty == nil { - return nil - } - - return &coralogixv1alpha1.PagerDuty{ - ServiceKey: pagerDuty.ServiceKey.GetValue(), - } -} - -func getOutgoingWebhookMicrosoftTeamsStatus(teams *cxsdk.MicrosoftTeamsConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.MicrosoftTeams { - if teams == nil { - return nil - } - - return &coralogixv1alpha1.MicrosoftTeams{ - Url: url.GetValue(), - } -} - -func getOutboundWebhookJiraStatus(jira *cxsdk.JiraConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.Jira { - if jira == nil { - return nil - } - - return &coralogixv1alpha1.Jira{ - ApiToken: jira.ApiToken.GetValue(), - Email: jira.Email.GetValue(), - ProjectKey: jira.ProjectKey.GetValue(), - Url: url.GetValue(), - } -} - -func getOutboundWebhookOpsgenieStatus(opsgenie *cxsdk.OpsgenieConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.Opsgenie { - if opsgenie == nil { - return nil - } - - return &coralogixv1alpha1.Opsgenie{ - Url: url.GetValue(), - } -} - -func getOutboundWebhookDemistoStatus(demisto *cxsdk.DemistoConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.Demisto { - if demisto == nil { - return nil - } - - return &coralogixv1alpha1.Demisto{ - Uuid: demisto.Uuid.GetValue(), - Payload: demisto.Payload.GetValue(), - Url: url.GetValue(), - } -} - -func flattenSlackDigests(digests []*cxsdk.SlackConfigDigest) []coralogixv1alpha1.SlackConfigDigest { - flattenedSlackDigests := make([]coralogixv1alpha1.SlackConfigDigest, 0, len(digests)) - for _, digest := range digests { - flattenedSlackDigests = append(flattenedSlackDigests, coralogixv1alpha1.SlackConfigDigest{ - Type: coralogixv1alpha1.SlackConfigDigestTypeFromProto[digest.Type], - IsActive: digest.IsActive.GetValue(), - }) - } - return flattenedSlackDigests -} - -func flattenSlackConfigAttachments(attachments []*cxsdk.SlackConfigAttachment) []coralogixv1alpha1.SlackConfigAttachment { - flattenedSlackConfigAttachments := make([]coralogixv1alpha1.SlackConfigAttachment, 0, len(attachments)) - for _, attachment := range attachments { - flattenedSlackConfigAttachments = append(flattenedSlackConfigAttachments, coralogixv1alpha1.SlackConfigAttachment{ - Type: coralogixv1alpha1.SlackConfigAttachmentTypeFromProto[attachment.Type], - IsActive: attachment.IsActive.GetValue(), - }) - } - return flattenedSlackConfigAttachments -} - -func getOutgoingWebhookSendLogStatus(sendLog *cxsdk.SendLogConfig, url *wrapperspb.StringValue) *coralogixv1alpha1.SendLogStatus { - if sendLog == nil { - return nil - } - - return &coralogixv1alpha1.SendLogStatus{ - Payload: sendLog.Payload.GetValue(), - Uuid: sendLog.Payload.GetValue(), - Url: url.GetValue(), - } -} - -func getOutgoingWebhookEmailGroupStatus(group *cxsdk.EmailGroupConfig) *coralogixv1alpha1.EmailGroup { - if group == nil { - return nil - } - - return &coralogixv1alpha1.EmailGroup{ - EmailAddresses: utils.WrappedStringSliceToStringSlice(group.EmailAddresses), - } -} - func (r *OutboundWebhookReconciler) update(ctx context.Context, log logr.Logger, webhook *coralogixv1alpha1.OutboundWebhook) error { updateReq, err := webhook.ExtractUpdateOutboundWebhookRequest() if err != nil { diff --git a/controllers/alphacontrollers/rulegroup_controller.go b/controllers/alphacontrollers/rulegroup_controller.go index 8289305..ab247e9 100644 --- a/controllers/alphacontrollers/rulegroup_controller.go +++ b/controllers/alphacontrollers/rulegroup_controller.go @@ -18,7 +18,6 @@ package alphacontrollers import ( "context" - "fmt" cxsdk "github.com/coralogix/coralogix-management-sdk/go" "github.com/coralogix/coralogix-operator/controllers/clientset" @@ -129,16 +128,15 @@ func (r *RuleGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } var ( - notFound bool - err error - actualState *coralogixv1alpha1.RuleGroupStatus + notFound bool + err error ) if id := ruleGroupCRD.Status.ID; id == nil { log.V(1).Info("ruleGroup wasn't created") notFound = true } else { - getRuleGroupResp, err := rulesGroupsClient.Get(ctx, &cxsdk.GetRuleGroupRequest{GroupId: *id}) + _, err := rulesGroupsClient.Get(ctx, &cxsdk.GetRuleGroupRequest{GroupId: *id}) switch { case status.Code(err) == codes.NotFound: log.V(1).Info("ruleGroup doesn't exist in Coralogix backend") @@ -146,12 +144,6 @@ func (r *RuleGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( case err != nil: log.Error(err, "Received an error while getting RuleGroup") return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err - case err == nil: - actualState, err = flattenRuleGroup(getRuleGroupResp.GetRuleGroup()) - if err != nil { - log.Error(err, "Error mapping coralogix API response", "Name", ruleGroupCRD.Name, "Namespace", ruleGroupCRD.Namespace) - return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err - } } } @@ -190,17 +182,15 @@ func (r *RuleGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err } - if equal, diff := ruleGroupCRD.Spec.DeepEqual(*actualState); !equal { - log.V(1).Info("Find diffs between spec and the actual state", "Diff", diff) - updateRuleGroupReq := ruleGroupCRD.Spec.ExtractUpdateRuleGroupRequest(*ruleGroupCRD.Status.ID) - updateRuleGroupResp, err := rulesGroupsClient.Update(ctx, updateRuleGroupReq) - if err != nil { - log.Error(err, "Received an error while updating a Rule-Group", "ruleGroup", updateRuleGroupReq) - return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err - } - jstr, _ := jsm.MarshalToString(updateRuleGroupResp) - log.V(1).Info("Rule-Group was updated", "ruleGroup", jstr) + log.V(1).Info("Updating Rule-Group", "ruleGroup") + updateRuleGroupReq := ruleGroupCRD.Spec.ExtractUpdateRuleGroupRequest(*ruleGroupCRD.Status.ID) + updateRuleGroupResp, err := rulesGroupsClient.Update(ctx, updateRuleGroupReq) + if err != nil { + log.Error(err, "Received an error while updating a Rule-Group", "ruleGroup", updateRuleGroupReq) + return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err } + jstr, _ := jsm.MarshalToString(updateRuleGroupResp) + log.V(1).Info("Rule-Group was updated", "ruleGroup", jstr) return ctrl.Result{}, nil } @@ -211,177 +201,9 @@ func flattenRuleGroup(ruleGroup *cxsdk.RuleGroup) (*coralogixv1alpha1.RuleGroupS status.ID = new(string) *status.ID = ruleGroup.GetId().GetValue() - status.Name = ruleGroup.GetName().GetValue() - - status.Active = ruleGroup.GetEnabled().GetValue() - - var err error - status.Applications, status.Subsystems, status.Severities, err = flattenRuleMatcher(ruleGroup.GetRuleMatchers()) - if err != nil { - return nil, fmt.Errorf("flattenRuleGroup name: %s: %w", ruleGroup.GetName().GetValue(), err) - } - - status.Description = ruleGroup.Description.GetValue() - - status.Order = new(int32) - *status.Order = int32(ruleGroup.GetOrder().GetValue()) - - status.Creator = ruleGroup.GetCreator().GetValue() - - status.Hidden = ruleGroup.GetHidden().GetValue() - - subGroups, err := flattenRuleSubGroups(ruleGroup.GetRuleSubgroups()) - if err != nil { - return nil, fmt.Errorf("flattenRuleGroup name: %s: %w", ruleGroup.GetName().GetValue(), err) - } - status.RuleSubgroups = subGroups return &status, nil } -func flattenRuleSubGroups(subgroups []*cxsdk.RuleSubgroup) ([]coralogixv1alpha1.RuleSubGroup, error) { - result := make([]coralogixv1alpha1.RuleSubGroup, 0, len(subgroups)) - for _, sg := range subgroups { - subgroup, err := flattenRuleSubGroup(sg) - if err != nil { - return nil, fmt.Errorf("flattenRuleSubGroups subGroupId: %s: %w", sg.GetId().GetValue(), err) - } - result = append(result, subgroup) - } - return result, nil -} - -func flattenRuleSubGroup(subGroup *cxsdk.RuleSubgroup) (coralogixv1alpha1.RuleSubGroup, error) { - var result coralogixv1alpha1.RuleSubGroup - - result.ID = new(string) - *result.ID = subGroup.Id.GetValue() - - result.Active = subGroup.GetEnabled().GetValue() - - result.Order = new(int32) - *result.Order = int32(subGroup.GetOrder().GetValue()) - - rules, err := flattenRules(subGroup.Rules) - if err != nil { - return coralogixv1alpha1.RuleSubGroup{}, fmt.Errorf("flattenRuleSubGroup: %w", err) - } - result.Rules = rules - return result, nil -} - -func flattenRules(rules []*cxsdk.Rule) ([]coralogixv1alpha1.Rule, error) { - result := make([]coralogixv1alpha1.Rule, 0, len(rules)) - for _, r := range rules { - rule, err := flattenRule(r) - if err != nil { - return nil, fmt.Errorf("flattenRules: %w", err) - } - result = append(result, rule) - } - return result, nil -} - -func flattenRule(rule *cxsdk.Rule) (coralogixv1alpha1.Rule, error) { - var result coralogixv1alpha1.Rule - result.Name = rule.GetName().GetValue() - result.Active = rule.GetEnabled().GetValue() - result.Description = rule.GetDescription().GetValue() - - switch ruleParams := rule.GetParameters().GetRuleParameters().(type) { - case *cxsdk.RuleParametersExtractParameters: - extractParameters := ruleParams.ExtractParameters - result.Extract = &coralogixv1alpha1.Extract{ - Regex: extractParameters.GetRule().GetValue(), - SourceField: rule.GetSourceField().GetValue(), - } - case *cxsdk.RuleParametersJSONExtractParameters: - jsonExtractParameters := ruleParams.JsonExtractParameters - result.JsonExtract = &coralogixv1alpha1.JsonExtract{ - JsonKey: jsonExtractParameters.GetRule().GetValue(), - DestinationField: coralogixv1alpha1.RulesProtoSeverityDestinationFieldToSchemaDestinationField[jsonExtractParameters.GetDestinationField()], - } - case *cxsdk.RuleParametersReplaceParameters: - replaceParameters := ruleParams.ReplaceParameters - result.Replace = &coralogixv1alpha1.Replace{ - SourceField: rule.GetSourceField().GetValue(), - DestinationField: replaceParameters.GetDestinationField().GetValue(), - Regex: replaceParameters.GetRule().GetValue(), - ReplacementString: replaceParameters.GetReplaceNewVal().GetValue(), - } - case *cxsdk.RuleParametersParseParameters: - parseParameters := ruleParams.ParseParameters - result.Parse = &coralogixv1alpha1.Parse{ - SourceField: rule.GetSourceField().GetValue(), - DestinationField: parseParameters.GetDestinationField().GetValue(), - Regex: parseParameters.GetRule().GetValue(), - } - case *cxsdk.RuleParametersAllowParameters: - allowParameters := ruleParams.AllowParameters - result.Block = &coralogixv1alpha1.Block{ - SourceField: rule.GetSourceField().GetValue(), - Regex: allowParameters.GetRule().GetValue(), - KeepBlockedLogs: allowParameters.GetKeepBlockedLogs().GetValue(), - BlockingAllMatchingBlocks: false, - } - case *cxsdk.RuleParametersBlockParameters: - blockParameters := ruleParams.BlockParameters - result.Block = &coralogixv1alpha1.Block{ - SourceField: rule.GetSourceField().GetValue(), - Regex: blockParameters.GetRule().GetValue(), - KeepBlockedLogs: blockParameters.GetKeepBlockedLogs().GetValue(), - BlockingAllMatchingBlocks: true, - } - case *cxsdk.RuleParametersExtractTimestampParameters: - extractTimestampParameters := ruleParams.ExtractTimestampParameters - result.ExtractTimestamp = &coralogixv1alpha1.ExtractTimestamp{ - SourceField: rule.GetSourceField().GetValue(), - TimeFormat: extractTimestampParameters.GetFormat().GetValue(), - FieldFormatStandard: coralogixv1alpha1.RulesProtoFormatStandardToSchemaFormatStandard[extractTimestampParameters.GetStandard()], - } - case *cxsdk.RuleParametersRemoveFieldsParameters: - removeFieldsParameters := ruleParams.RemoveFieldsParameters - result.RemoveFields = &coralogixv1alpha1.RemoveFields{ - ExcludedFields: removeFieldsParameters.GetFields(), - } - case *cxsdk.RuleParametersJSONStringifyParameters: - jsonStringifyParameters := ruleParams.JsonStringifyParameters - result.JsonStringify = &coralogixv1alpha1.JsonStringify{ - SourceField: rule.GetSourceField().GetValue(), - DestinationField: jsonStringifyParameters.GetDestinationField().GetValue(), - KeepSourceField: !(jsonStringifyParameters.GetDeleteSource().GetValue()), - } - case *cxsdk.RuleParametersJSONParseParameters: - jsonParseParameters := ruleParams.JsonParseParameters - result.ParseJsonField = &coralogixv1alpha1.ParseJsonField{ - SourceField: rule.GetSourceField().GetValue(), - DestinationField: jsonParseParameters.GetDestinationField().GetValue(), - KeepSourceField: !(jsonParseParameters.GetDeleteSource().GetValue()), - KeepDestinationField: !(jsonParseParameters.GetOverrideDest().GetValue()), - } - default: - return coralogixv1alpha1.Rule{}, fmt.Errorf("unexpected type %T for rule parameters, name: %s", ruleParams, rule.GetName().GetValue()) - } - return result, nil -} - -func flattenRuleMatcher(ruleMatchers []*cxsdk.RuleMatcher) (applications, subsystems []string, severities []coralogixv1alpha1.RuleSeverity, err error) { - for _, ruleMatcher := range ruleMatchers { - switch matcher := ruleMatcher.Constraint.(type) { - case *cxsdk.RuleMatcherApplicationName: - applications = append(applications, matcher.ApplicationName.GetValue().GetValue()) - case *cxsdk.RuleMatcherSubsystemName: - subsystems = append(subsystems, matcher.SubsystemName.GetValue().GetValue()) - case *cxsdk.RuleMatcherSeverity: - severity := matcher.Severity.GetValue() - severities = append(severities, coralogixv1alpha1.RulesProtoSeverityToSchemaSeverity[severity]) - default: - return nil, nil, nil, fmt.Errorf("unexpected type %T for rule matcher", ruleMatcher) - } - } - - return -} - // SetupWithManager sets up the controller with the Manager. func (r *RuleGroupReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). diff --git a/controllers/alphacontrollers/rulegroup_controller_test.go b/controllers/alphacontrollers/rulegroup_controller_test.go index d02445d..a6e50cd 100644 --- a/controllers/alphacontrollers/rulegroup_controller_test.go +++ b/controllers/alphacontrollers/rulegroup_controller_test.go @@ -129,38 +129,8 @@ func TestFlattenRuleGroups(t *testing.T) { assert.NoError(t, err) id := "id" - subgroupId := "subgroup_id" expectedStatus := &coralogixv1alpha1.RuleGroupStatus{ - ID: &id, - Name: "name", - Description: "description", - Active: true, - Applications: nil, - Subsystems: nil, - Severities: nil, - Hidden: false, - Creator: "creator", - Order: pointer.Int32(1), - RuleSubgroups: []coralogixv1alpha1.RuleSubGroup{ - { - ID: &subgroupId, - Active: false, - Order: pointer.Int32(1), - Rules: []coralogixv1alpha1.Rule{ - { - Name: "rule_name", - Description: "rule_description", - Active: true, - Parse: nil, - Block: nil, - JsonExtract: &coralogixv1alpha1.JsonExtract{ - DestinationField: coralogixv1alpha1.DestinationFieldRuleSeverity, - JsonKey: "{\"severity\": \"info\"}", - }, - }, - }, - }, - }, + ID: &id, } assert.Equal(t, expectedStatus, actualStatus) diff --git a/docs/api.md b/docs/api.md index f125d05..b19d8fd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -2353,91 +2353,99 @@ AlertStatus defines the observed state of Alert
true + + + +## OutboundWebhook +[↩ Parent](#coralogixcomv1alpha1 ) + + + + + + +OutboundWebhook is the Schema for the outboundwebhooks API + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + - - - - - - + - - - - - - + +
NameTypeDescriptionRequired
apiVersionstringcoralogix.com/v1alpha1true
kindstringOutboundWebhooktrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
activeboolean -
-
false
alertTypespec object -
-
false
descriptionstring -
+ OutboundWebhookSpec defines the desired state of OutboundWebhook
false
expirationDatestatus object -
-
false
labelsmap[string]string -
+ OutboundWebhookStatus defines the observed state of OutboundWebhook
false
+ + +### OutboundWebhook.spec +[↩ Parent](#outboundwebhook) + + + +OutboundWebhookSpec defines the desired state of OutboundWebhook + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + - + - +
NameTypeDescriptionRequired
name string
false
notificationGroups[]object -
-
false
payloadFilters[]string -
-
false
schedulingobject -
-
false
severityenum -
-
- Enum: Info, Warning, Critical, Error
-
falsetrue
showInInsightoutboundWebhookType object
falsetrue
-### Alert.status.alertType -[↩ Parent](#alertstatus) +### OutboundWebhook.spec.outboundWebhookType +[↩ Parent](#outboundwebhookspec) @@ -2453,56 +2461,70 @@ AlertStatus defines the observed state of Alert - flow + awsEventBridge + object + +
+ + false + + demisto + object + +
+ + false + + emailGroup object
false - metric + genericWebhook object
false - newValue + jira object
false - ratio + microsoftTeams object
false - standard + opsgenie object
false - timeRelative + pagerDuty object
false - tracing + sendLog object
false - uniqueCount + slack object
@@ -2512,8 +2534,8 @@ AlertStatus defines the observed state of Alert -### Alert.status.alertType.flow -[↩ Parent](#alertstatusalerttype) +### OutboundWebhook.spec.outboundWebhookType.awsEventBridge +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2529,52 +2551,46 @@ AlertStatus defines the observed state of Alert - stages - []object + detail + string
true - - - - -### Alert.status.alertType.flow.stages[index] -[↩ Parent](#alertstatusalerttypeflow) - - - - - - - - - - - - - - - - - + + + - - + + - + + + + + + + + + + +
NameTypeDescriptionRequired
groups[]object
detailTypestring
true
timeWindowobjecteventBusArnstring
falsetrue
roleNamestring +
+
true
sourcestring +
+
true
-### Alert.status.alertType.flow.stages[index].groups[index] -[↩ Parent](#alertstatusalerttypeflowstagesindex) +### OutboundWebhook.spec.outboundWebhookType.demisto +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2590,27 +2606,32 @@ AlertStatus defines the observed state of Alert - innerFlowAlerts - object + payload + string
true - nextOperator - enum + url + string
+ + true + + uuid + string +
- Enum: And, Or
true -### Alert.status.alertType.flow.stages[index].groups[index].innerFlowAlerts -[↩ Parent](#alertstatusalerttypeflowstagesindexgroupsindex) +### OutboundWebhook.spec.outboundWebhookType.emailGroup +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2626,27 +2647,18 @@ AlertStatus defines the observed state of Alert - alerts - []object - -
- - true - - operator - enum + emailAddresses + []string
-
- Enum: And, Or
true -### Alert.status.alertType.flow.stages[index].groups[index].innerFlowAlerts.alerts[index] -[↩ Parent](#alertstatusalerttypeflowstagesindexgroupsindexinnerflowalerts) +### OutboundWebhook.spec.outboundWebhookType.genericWebhook +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2662,16 +2674,30 @@ AlertStatus defines the observed state of Alert - not - boolean + method + enum

- Default: false
+ Enum: Unkown, Get, Post, Put
+ + true + + url + string + +
+ + true + + headers + map[string]string + +
false - userAlertId + payload string
@@ -2681,8 +2707,8 @@ AlertStatus defines the observed state of Alert -### Alert.status.alertType.flow.stages[index].timeWindow -[↩ Parent](#alertstatusalerttypeflowstagesindex) +### OutboundWebhook.spec.outboundWebhookType.jira +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2698,32 +2724,39 @@ AlertStatus defines the observed state of Alert - hours - integer + apiToken + string
- false + true - minutes - integer + email + string
- false + true - seconds - integer + projectKey + string
- false + true + + url + string + +
+ + true -### Alert.status.alertType.metric -[↩ Parent](#alertstatusalerttype) +### OutboundWebhook.spec.outboundWebhookType.microsoftTeams +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2739,25 +2772,18 @@ AlertStatus defines the observed state of Alert - lucene - object - -
- - false - - promql - object + url + string
- false + true -### Alert.status.alertType.metric.lucene -[↩ Parent](#alertstatusalerttypemetric) +### OutboundWebhook.spec.outboundWebhookType.opsgenie +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2773,25 +2799,18 @@ AlertStatus defines the observed state of Alert - conditions - object - -
- - true - - searchQuery + url string
- false + true -### Alert.status.alertType.metric.lucene.conditions -[↩ Parent](#alertstatusalerttypemetriclucene) +### OutboundWebhook.spec.outboundWebhookType.pagerDuty +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2807,100 +2826,18 @@ AlertStatus defines the observed state of Alert - alertWhen - enum - -
-
- Enum: More, Less
- - true - - arithmeticOperator - enum - -
-
- Enum: Avg, Min, Max, Sum, Count, Percentile
- - true - - metricField + serviceKey string
true - - threshold - int or string - -
- - true - - timeWindow - enum - -
-
- Enum: Minute, FiveMinutes, TenMinutes, FifteenMinutes, TwentyMinutes, ThirtyMinutes, Hour, TwoHours, FourHours, SixHours, TwelveHours, TwentyFourHours
- - true - - arithmeticOperatorModifier - integer - -
- - false - - groupBy - []string - -
- - false - - manageUndetectedValues - object - -
- - false - - minNonNullValuesPercentage - integer - -
-
- Minimum: 0
- - false - - replaceMissingValueWithZero - boolean - -
-
- Default: false
- - false - - sampleThresholdPercentage - integer - -
-
- Minimum: 0
- - false -### Alert.status.alertType.metric.lucene.conditions.manageUndetectedValues -[↩ Parent](#alertstatusalerttypemetricluceneconditions) +### OutboundWebhook.spec.outboundWebhookType.sendLog +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2916,30 +2853,25 @@ AlertStatus defines the observed state of Alert - autoRetireRatio - enum + payload + string
-
- Enum: Never, FiveMinutes, TenMinutes, Hour, TwoHours, SixHours, TwelveHours, TwentyFourHours
- Default: Never
- false + true - enableTriggeringOnUndetectedValues - boolean + url + string
-
- Default: true
- false + true -### Alert.status.alertType.metric.promql -[↩ Parent](#alertstatusalerttypemetric) +### OutboundWebhook.spec.outboundWebhookType.slack +[↩ Parent](#outboundwebhookspecoutboundwebhooktype) @@ -2955,15 +2887,22 @@ AlertStatus defines the observed state of Alert - conditions - object + url + string
true - searchQuery - string + attachments + []object + +
+ + false + + digests + []object
@@ -2972,8 +2911,8 @@ AlertStatus defines the observed state of Alert -### Alert.status.alertType.metric.promql.conditions -[↩ Parent](#alertstatusalerttypemetricpromql) +### OutboundWebhook.spec.outboundWebhookType.slack.attachments[index] +[↩ Parent](#outboundwebhookspecoutboundwebhooktypeslack) @@ -2989,68 +2928,25 @@ AlertStatus defines the observed state of Alert - alertWhen - enum - -
-
- Enum: More, Less, MoreThanUsual
- - true - - threshold - int or string + isActive + boolean
true - timeWindow - enum + type + string
-
- Enum: Minute, FiveMinutes, TenMinutes, FifteenMinutes, TwentyMinutes, ThirtyMinutes, Hour, TwoHours, FourHours, SixHours, TwelveHours, TwentyFourHours
true - - manageUndetectedValues - object - -
- - false - - minNonNullValuesPercentage - integer - -
-
- Minimum: 0
- - false - - replaceMissingValueWithZero - boolean - -
- - false - - sampleThresholdPercentage - integer - -
-
- Minimum: 0
- - false -### Alert.status.alertType.metric.promql.conditions.manageUndetectedValues -[↩ Parent](#alertstatusalerttypemetricpromqlconditions) +### OutboundWebhook.spec.outboundWebhookType.slack.digests[index] +[↩ Parent](#outboundwebhookspecoutboundwebhooktypeslack) @@ -3066,34 +2962,29 @@ AlertStatus defines the observed state of Alert - autoRetireRatio - enum + isActive + boolean
-
- Enum: Never, FiveMinutes, TenMinutes, Hour, TwoHours, SixHours, TwelveHours, TwentyFourHours
- Default: Never
- false + true - enableTriggeringOnUndetectedValues - boolean + type + string
-
- Default: true
- false + true -### Alert.status.alertType.newValue -[↩ Parent](#alertstatusalerttype) - +### OutboundWebhook.status +[↩ Parent](#outboundwebhook) +OutboundWebhookStatus defines the observed state of OutboundWebhook @@ -3105,15 +2996,15 @@ AlertStatus defines the observed state of Alert - - + + - - + + @@ -3121,13 +3012,15 @@ AlertStatus defines the observed state of Alert
conditionsobjectidstring
true
filtersobjectexternalIdstring
+## RecordingRuleGroupSet +[↩ Parent](#coralogixcomv1alpha1 ) + -### Alert.status.alertType.newValue.conditions -[↩ Parent](#alertstatusalerttypenewvalue) +RecordingRuleGroupSet is the Schema for the recordingrulegroupsets API @@ -3139,3425 +3032,46 @@ AlertStatus defines the observed state of Alert - - - - - - - - - - -
keystring -
-
true
timeWindowenum -
-
- Enum: TwelveHours, TwentyFourHours, FortyEightHours, SeventTwoHours, Week, Month, TwoMonths, ThreeMonths
-
true
- - -### Alert.status.alertType.newValue.filters -[↩ Parent](#alertstatusalerttypenewvalue) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
aliasstring -
-
false
applications[]string -
-
false
categories[]string -
-
false
classes[]string -
-
false
computers[]string -
-
false
ips[]string -
-
false
methods[]string -
-
false
searchQuerystring -
-
false
severities[]enum -
-
false
subsystems[]string -
-
false
- - -### Alert.status.alertType.ratio -[↩ Parent](#alertstatusalerttype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
conditionsobject -
-
true
q1Filtersobject -
-
false
q2Filtersobject -
-
false
- - -### Alert.status.alertType.ratio.conditions -[↩ Parent](#alertstatusalerttyperatio) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
alertWhenenum -
-
- Enum: More, Less
-
true
ratioint or string -
-
true
timeWindowenum -
-
- Enum: FiveMinutes, TenMinutes, FifteenMinutes, TwentyMinutes, ThirtyMinutes, Hour, TwoHours, FourHours, SixHours, TwelveHours, TwentyFourHours, ThirtySixHours
-
true
groupBy[]string -
-
false
groupByForenum -
-
- Enum: Q1, Q2, Both
-
false
ignoreInfinityboolean -
-
- Default: false
-
false
manageUndetectedValuesobject -
-
false
- - -### Alert.status.alertType.ratio.conditions.manageUndetectedValues -[↩ Parent](#alertstatusalerttyperatioconditions) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
autoRetireRatioenum -
-
- Enum: Never, FiveMinutes, TenMinutes, Hour, TwoHours, SixHours, TwelveHours, TwentyFourHours
- Default: Never
-
false
enableTriggeringOnUndetectedValuesboolean -
-
- Default: true
-
false
- - -### Alert.status.alertType.ratio.q1Filters -[↩ Parent](#alertstatusalerttyperatio) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
aliasstring -
-
false
applications[]string -
-
false
categories[]string -
-
false
classes[]string -
-
false
computers[]string -
-
false
ips[]string -
-
false
methods[]string -
-
false
searchQuerystring -
-
false
severities[]enum -
-
false
subsystems[]string -
-
false
- - -### Alert.status.alertType.ratio.q2Filters -[↩ Parent](#alertstatusalerttyperatio) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
aliasstring -
-
false
applications[]string -
-
false
searchQuerystring -
-
false
severities[]enum -
-
false
subsystems[]string -
-
false
- - -### Alert.status.alertType.standard -[↩ Parent](#alertstatusalerttype) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
conditionsobject -
-
true
filtersobject -
-
false
- - -### Alert.status.alertType.standard.conditions -[↩ Parent](#alertstatusalerttypestandard) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
alertWhenenum -
-
- Enum: More, Less, Immediately, MoreThanUsual
-
true
groupBy[]string -
-
false
manageUndetectedValuesobject -
-
false
thresholdinteger -
-
false
timeWindowenum -
-
- Enum: FiveMinutes, TenMinutes, FifteenMinutes, TwentyMinutes, ThirtyMinutes, Hour, TwoHours, FourHours, SixHours, TwelveHours, TwentyFourHours, ThirtySixHours
-
false
- - -### Alert.status.alertType.standard.conditions.manageUndetectedValues -[↩ Parent](#alertstatusalerttypestandardconditions) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
autoRetireRatioenum -
-
- Enum: Never, FiveMinutes, TenMinutes, Hour, TwoHours, SixHours, TwelveHours, TwentyFourHours
- Default: Never
-
false
enableTriggeringOnUndetectedValuesboolean -
-
- Default: true
-
false
- - -### Alert.status.alertType.standard.filters -[↩ Parent](#alertstatusalerttypestandard) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
aliasstring -
-
false
applications[]string -
-
false
categories[]string -
-
false
classes[]string -
-
false
computers[]string -
-
false
ips[]string -
-
false
methods[]string -
-
false
searchQuerystring -
-
false
severities[]enum -
-
false
subsystems[]string -
-
false
- - -### Alert.status.alertType.timeRelative -[↩ Parent](#alertstatusalerttype) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
conditionsobject -
-
true
filtersobject -
-
false
- - -### Alert.status.alertType.timeRelative.conditions -[↩ Parent](#alertstatusalerttypetimerelative) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
alertWhenenum -
-
- Enum: More, Less
-
true
thresholdint or string -
-
true
timeWindowenum -
-
- Enum: PreviousHour, SameHourYesterday, SameHourLastWeek, Yesterday, SameDayLastWeek, SameDayLastMonth
-
true
groupBy[]string -
-
false
ignoreInfinityboolean -
-
- Default: false
-
false
manageUndetectedValuesobject -
-
false
- - -### Alert.status.alertType.timeRelative.conditions.manageUndetectedValues -[↩ Parent](#alertstatusalerttypetimerelativeconditions) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
autoRetireRatioenum -
-
- Enum: Never, FiveMinutes, TenMinutes, Hour, TwoHours, SixHours, TwelveHours, TwentyFourHours
- Default: Never
-
false
enableTriggeringOnUndetectedValuesboolean -
-
- Default: true
-
false
- - -### Alert.status.alertType.timeRelative.filters -[↩ Parent](#alertstatusalerttypetimerelative) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
aliasstring -
-
false
applications[]string -
-
false
categories[]string -
-
false
classes[]string -
-
false
computers[]string -
-
false
ips[]string -
-
false
methods[]string -
-
false
searchQuerystring -
-
false
severities[]enum -
-
false
subsystems[]string -
-
false
- - -### Alert.status.alertType.tracing -[↩ Parent](#alertstatusalerttype) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
conditionsobject -
-
true
filtersobject -
-
false
- - -### Alert.status.alertType.tracing.conditions -[↩ Parent](#alertstatusalerttypetracing) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
alertWhenenum -
-
- Enum: More, Immediately
-
true
groupBy[]string -
-
false
thresholdinteger -
-
false
timeWindowenum -
-
- Enum: FiveMinutes, TenMinutes, FifteenMinutes, TwentyMinutes, ThirtyMinutes, Hour, TwoHours, FourHours, SixHours, TwelveHours, TwentyFourHours, ThirtySixHours
-
false
- - -### Alert.status.alertType.tracing.filters -[↩ Parent](#alertstatusalerttypetracing) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
applications[]string -
-
false
latencyThresholdMillisecondsint or string -
-
false
services[]string -
-
false
subsystems[]string -
-
false
tagFilters[]object -
-
false
- - -### Alert.status.alertType.tracing.filters.tagFilters[index] -[↩ Parent](#alertstatusalerttypetracingfilters) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
fieldstring -
-
false
values[]string -
-
false
- - -### Alert.status.alertType.uniqueCount -[↩ Parent](#alertstatusalerttype) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
conditionsobject -
-
true
filtersobject -
-
false
- - -### Alert.status.alertType.uniqueCount.conditions -[↩ Parent](#alertstatusalerttypeuniquecount) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
keystring -
-
true
maxUniqueValuesinteger -
-
- Minimum: 1
-
true
timeWindowenum -
-
- Enum: Minute, FiveMinutes, TenMinutes, FifteenMinutes, TwentyMinutes, ThirtyMinutes, Hour, TwoHours, FourHours, SixHours, TwelveHours, TwentyFourHours, ThirtySixHours
-
true
groupBystring -
-
false
maxUniqueValuesForGroupByinteger -
-
- Minimum: 1
-
false
- - -### Alert.status.alertType.uniqueCount.filters -[↩ Parent](#alertstatusalerttypeuniquecount) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
aliasstring -
-
false
applications[]string -
-
false
categories[]string -
-
false
classes[]string -
-
false
computers[]string -
-
false
ips[]string -
-
false
methods[]string -
-
false
searchQuerystring -
-
false
severities[]enum -
-
false
subsystems[]string -
-
false
- - -### Alert.status.expirationDate -[↩ Parent](#alertstatus) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
dayinteger -
-
- Format: int32
- Minimum: 1
- Maximum: 31
-
false
monthinteger -
-
- Format: int32
- Minimum: 1
- Maximum: 12
-
false
yearinteger -
-
- Format: int32
- Minimum: 1
- Maximum: 9999
-
false
- - -### Alert.status.notificationGroups[index] -[↩ Parent](#alertstatus) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
groupByFields[]string -
-
false
notifications[]object -
-
false
- - -### Alert.status.notificationGroups[index].notifications[index] -[↩ Parent](#alertstatusnotificationgroupsindex) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
emailRecipients[]string -
-
false
integrationNamestring -
-
false
notifyOnenum -
-
- Enum: TriggeredOnly, TriggeredAndResolved
-
false
retriggeringPeriodMinutesinteger -
-
- Format: int32
-
false
- - -### Alert.status.scheduling -[↩ Parent](#alertstatus) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
daysEnabled[]enum -
-
false
endTimestring -
-
false
startTimestring -
-
false
timeZonestring -
-
- Default: UTC+00
-
false
- - -### Alert.status.showInInsight -[↩ Parent](#alertstatus) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
notifyOnenum -
-
- Enum: TriggeredOnly, TriggeredAndResolved
- Default: TriggeredOnly
-
false
retriggeringPeriodMinutesinteger -
-
- Format: int32
- Minimum: 1
-
false
- -## OutboundWebhook -[↩ Parent](#coralogixcomv1alpha1 ) - - - - - - -OutboundWebhook is the Schema for the outboundwebhooks API - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
apiVersionstringcoralogix.com/v1alpha1true
kindstringOutboundWebhooktrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
specobject - OutboundWebhookSpec defines the desired state of OutboundWebhook
-
false
statusobject - OutboundWebhookStatus defines the observed state of OutboundWebhook
-
false
- - -### OutboundWebhook.spec -[↩ Parent](#outboundwebhook) - - - -OutboundWebhookSpec defines the desired state of OutboundWebhook - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
namestring -
-
true
outboundWebhookTypeobject -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType -[↩ Parent](#outboundwebhookspec) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
awsEventBridgeobject -
-
false
demistoobject -
-
false
emailGroupobject -
-
false
genericWebhookobject -
-
false
jiraobject -
-
false
microsoftTeamsobject -
-
false
opsgenieobject -
-
false
pagerDutyobject -
-
false
sendLogobject -
-
false
slackobject -
-
false
- - -### OutboundWebhook.spec.outboundWebhookType.awsEventBridge -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
detailstring -
-
true
detailTypestring -
-
true
eventBusArnstring -
-
true
roleNamestring -
-
true
sourcestring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.demisto -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
payloadstring -
-
true
urlstring -
-
true
uuidstring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.emailGroup -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
emailAddresses[]string -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.genericWebhook -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
methodenum -
-
- Enum: Unkown, Get, Post, Put
-
true
urlstring -
-
true
headersmap[string]string -
-
false
payloadstring -
-
false
- - -### OutboundWebhook.spec.outboundWebhookType.jira -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
apiTokenstring -
-
true
emailstring -
-
true
projectKeystring -
-
true
urlstring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.microsoftTeams -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
urlstring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.opsgenie -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
urlstring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.pagerDuty -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
serviceKeystring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.sendLog -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
payloadstring -
-
true
urlstring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.slack -[↩ Parent](#outboundwebhookspecoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
urlstring -
-
true
attachments[]object -
-
false
digests[]object -
-
false
- - -### OutboundWebhook.spec.outboundWebhookType.slack.attachments[index] -[↩ Parent](#outboundwebhookspecoutboundwebhooktypeslack) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
isActiveboolean -
-
true
typestring -
-
true
- - -### OutboundWebhook.spec.outboundWebhookType.slack.digests[index] -[↩ Parent](#outboundwebhookspecoutboundwebhooktypeslack) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
isActiveboolean -
-
true
typestring -
-
true
- - -### OutboundWebhook.status -[↩ Parent](#outboundwebhook) - - - -OutboundWebhookStatus defines the observed state of OutboundWebhook - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
idstring -
-
true
namestring -
-
true
outboundWebhookTypeobject -
-
true
externalIdstring -
-
false
- - -### OutboundWebhook.status.outboundWebhookType -[↩ Parent](#outboundwebhookstatus) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
awsEventBridgeobject -
-
false
demistoobject -
-
false
emailGroupobject -
-
false
genericWebhookobject -
-
false
jiraobject -
-
false
microsoftTeamsobject -
-
false
opsgenieobject -
-
false
pagerDutyobject -
-
false
sendLogobject -
-
false
slackobject -
-
false
- - -### OutboundWebhook.status.outboundWebhookType.awsEventBridge -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
detailstring -
-
true
detailTypestring -
-
true
eventBusArnstring -
-
true
roleNamestring -
-
true
sourcestring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.demisto -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
payloadstring -
-
true
urlstring -
-
true
uuidstring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.emailGroup -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
emailAddresses[]string -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.genericWebhook -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
methodenum -
-
- Enum: Unkown, Get, Post, Put
-
true
urlstring -
-
true
uuidstring -
-
true
headersmap[string]string -
-
false
payloadstring -
-
false
- - -### OutboundWebhook.status.outboundWebhookType.jira -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
apiTokenstring -
-
true
emailstring -
-
true
projectKeystring -
-
true
urlstring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.microsoftTeams -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
urlstring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.opsgenie -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
urlstring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.pagerDuty -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
serviceKeystring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.sendLog -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
payloadstring -
-
true
urlstring -
-
true
uuidstring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.slack -[↩ Parent](#outboundwebhookstatusoutboundwebhooktype) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
urlstring -
-
true
attachments[]object -
-
false
digests[]object -
-
false
- - -### OutboundWebhook.status.outboundWebhookType.slack.attachments[index] -[↩ Parent](#outboundwebhookstatusoutboundwebhooktypeslack) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
isActiveboolean -
-
true
typestring -
-
true
- - -### OutboundWebhook.status.outboundWebhookType.slack.digests[index] -[↩ Parent](#outboundwebhookstatusoutboundwebhooktypeslack) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
isActiveboolean -
-
true
typestring -
-
true
- -## RecordingRuleGroupSet -[↩ Parent](#coralogixcomv1alpha1 ) - - - - - - -RecordingRuleGroupSet is the Schema for the recordingrulegroupsets API - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
apiVersionstringcoralogix.com/v1alpha1true
kindstringRecordingRuleGroupSettrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
specobject - RecordingRuleGroupSetSpec defines the desired state of RecordingRuleGroupSet
-
false
statusobject - RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet
-
false
- - -### RecordingRuleGroupSet.spec -[↩ Parent](#recordingrulegroupset) - - - -RecordingRuleGroupSetSpec defines the desired state of RecordingRuleGroupSet - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
groups[]object -
-
true
- - -### RecordingRuleGroupSet.spec.groups[index] -[↩ Parent](#recordingrulegroupsetspec) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
intervalSecondsinteger -
-
- Format: int32
- Default: 60
-
false
limitinteger -
-
- Format: int64
-
false
namestring - INSERT ADDITIONAL SPEC FIELDS - desired state of cluster -Important: Run "make" to regenerate code after modifying this file
-
false
rules[]object -
-
false
- - -### RecordingRuleGroupSet.spec.groups[index].rules[index] -[↩ Parent](#recordingrulegroupsetspecgroupsindex) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
exprstring -
-
false
labelsmap[string]string -
-
false
recordstring -
-
false
- - -### RecordingRuleGroupSet.status -[↩ Parent](#recordingrulegroupset) - - - -RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
idstring -
-
true
groups[]object -
-
false
- - -### RecordingRuleGroupSet.status.groups[index] -[↩ Parent](#recordingrulegroupsetstatus) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
intervalSecondsinteger -
-
- Format: int32
- Default: 60
-
false
limitinteger -
-
- Format: int64
-
false
namestring - INSERT ADDITIONAL SPEC FIELDS - desired state of cluster -Important: Run "make" to regenerate code after modifying this file
-
false
rules[]object -
-
false
- - -### RecordingRuleGroupSet.status.groups[index].rules[index] -[↩ Parent](#recordingrulegroupsetstatusgroupsindex) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
exprstring -
-
false
labelsmap[string]string -
-
false
recordstring -
-
false
- -## RuleGroup -[↩ Parent](#coralogixcomv1alpha1 ) - - - - - - -RuleGroup is the Schema for the rulegroups API - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
apiVersionstringcoralogix.com/v1alpha1true
kindstringRuleGrouptrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
specobject - RuleGroupSpec defines the Desired state of RuleGroup
-
false
statusobject - RuleGroupStatus defines the observed state of RuleGroup
-
false
- - -### RuleGroup.spec -[↩ Parent](#rulegroup) - - - -RuleGroupSpec defines the Desired state of RuleGroup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
namestring -
-
true
activeboolean -
-
- Default: true
-
false
applications[]string -
-
false
creatorstring -
-
false
descriptionstring -
-
false
hiddenboolean -
-
- Default: false
-
false
orderinteger -
-
- Format: int32
- Minimum: 1
-
false
severities[]enum -
-
false
subgroups[]object -
-
false
subsystems[]string -
-
false
- - -### RuleGroup.spec.subgroups[index] -[↩ Parent](#rulegroupspec) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
activeboolean -
-
- Default: true
-
false
idstring -
-
false
orderinteger -
-
- Format: int32
-
false
rules[]object -
-
false
- - -### RuleGroup.spec.subgroups[index].rules[index] -[↩ Parent](#rulegroupspecsubgroupsindex) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - -
NameTypeDescriptionRequired
namestring -
-
true
activeboolean -
-
- Default: true
-
false
blockobject -
-
false
descriptionstring -
-
false
extractobject -
-
false
extractTimestampobject -
-
false
jsonExtractobject -
-
false
jsonStringifyobject -
-
false
parseobject -
-
false
parseJsonFieldobject -
-
false
removeFieldsobject -
-
falseapiVersionstringcoralogix.com/v1alpha1true
kindstringRecordingRuleGroupSettrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
replacespec object -
-
false
- - -### RuleGroup.spec.subgroups[index].rules[index].block -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
regexstring -
-
true
sourceFieldstring -
-
true
blockingAllMatchingBlocksboolean -
-
- Default: true
-
false
keepBlockedLogsboolean -
-
- Default: false
+ RecordingRuleGroupSetSpec defines the desired state of RecordingRuleGroupSet
false
- - -### RuleGroup.spec.subgroups[index].rules[index].extract -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescriptionRequired
regexstring -
-
true
sourceFieldstring -
-
true
- - -### RuleGroup.spec.subgroups[index].rules[index].extractTimestamp -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - +
NameTypeDescriptionRequired
fieldFormatStandardenum -
-
- Enum: Strftime, JavaSDF, Golang, SecondTS, MilliTS, MicroTS, NanoTS
-
true
sourceFieldstring -
-
true
timeFormatstring
statusobject -
+ RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet
truefalse
-### RuleGroup.spec.subgroups[index].rules[index].jsonExtract -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) - +### RecordingRuleGroupSet.spec +[↩ Parent](#recordingrulegroupset) +RecordingRuleGroupSetSpec defines the desired state of RecordingRuleGroupSet @@ -6569,17 +3083,8 @@ RuleGroupSpec defines the Desired state of RuleGroup - - - - - - - + + @@ -6588,8 +3093,8 @@ RuleGroupSpec defines the Desired state of RuleGroup
destinationFieldenum -
-
- Enum: Category, CLASSNAME, METHODNAME, THREADID, SEVERITY
-
true
jsonKeystringgroups[]object
-### RuleGroup.spec.subgroups[index].rules[index].jsonStringify -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) +### RecordingRuleGroupSet.spec.groups[index] +[↩ Parent](#recordingrulegroupsetspec) @@ -6605,75 +3110,45 @@ RuleGroupSpec defines the Desired state of RuleGroup - destinationField - string + intervalSeconds + integer
- - true - - sourceField - string -
+ Format: int32
+ Default: 60
- true + false - keepSourceField - boolean + limit + integer

- Default: false
+ Format: int64
false - - - - -### RuleGroup.spec.subgroups[index].rules[index].parse -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) - - - - - - - - - - - - - - - - - - - - + - + - - + + - +
NameTypeDescriptionRequired
destinationFieldstring -
-
true
regexname string -
+ INSERT ADDITIONAL SPEC FIELDS - desired state of cluster +Important: Run "make" to regenerate code after modifying this file
truefalse
sourceFieldstringrules[]object
truefalse
-### RuleGroup.spec.subgroups[index].rules[index].parseJsonField -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) +### RecordingRuleGroupSet.spec.groups[index].rules[index] +[↩ Parent](#recordingrulegroupsetspecgroupsindex) @@ -6689,43 +3164,36 @@ RuleGroupSpec defines the Desired state of RuleGroup - destinationField + expr string
- true - - keepDestinationField - boolean - -
- - true + false - keepSourceField - boolean + labels + map[string]string
- true + false - sourceField + record string
- true + false -### RuleGroup.spec.subgroups[index].rules[index].removeFields -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) - +### RecordingRuleGroupSet.status +[↩ Parent](#recordingrulegroupset) +RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet @@ -6737,8 +3205,8 @@ RuleGroupSpec defines the Desired state of RuleGroup - - + + @@ -6746,13 +3214,15 @@ RuleGroupSpec defines the Desired state of RuleGroup
excludedFields[]stringidstring
+## RuleGroup +[↩ Parent](#coralogixcomv1alpha1 ) + -### RuleGroup.spec.subgroups[index].rules[index].replace -[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) +RuleGroup is the Schema for the rulegroups API @@ -6764,43 +3234,46 @@ RuleGroupSpec defines the Desired state of RuleGroup - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - + - - + + - +
destinationFieldstring -
-
true
regexstring -
-
trueapiVersionstringcoralogix.com/v1alpha1true
kindstringRuleGrouptrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
replacementStringstringspecobject -
+ RuleGroupSpec defines the Desired state of RuleGroup
truefalse
sourceFieldstringstatusobject -
+ RuleGroupStatus defines the observed state of RuleGroup
truefalse
-### RuleGroup.status +### RuleGroup.spec [↩ Parent](#rulegroup) -RuleGroupStatus defines the observed state of RuleGroup +RuleGroupSpec defines the Desired state of RuleGroup @@ -6812,11 +3285,10 @@ RuleGroupStatus defines the observed state of RuleGroup - + @@ -6824,6 +3296,8 @@ Important: Run "make" to regenerate code after modifying this file
@@ -6852,13 +3326,8 @@ Important: Run "make" to regenerate code after modifying this file
- - - - - @@ -6868,6 +3337,7 @@ Important: Run "make" to regenerate code after modifying this file


Format: int32
+ Minimum: 1
@@ -6878,7 +3348,7 @@ Important: Run "make" to regenerate code after modifying this file
- +
idname string - INSERT ADDITIONAL STATUS FIELD - define observed state of cluster -Important: Run "make" to regenerate code after modifying this file
+
true
boolean
+
+ Default: true
false
boolean
-
false
namestring
+ Default: false
false
false
false
subgroupssubgroups []object
@@ -6895,8 +3365,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index] -[↩ Parent](#rulegroupstatus) +### RuleGroup.spec.subgroups[index] +[↩ Parent](#rulegroupspec) @@ -6937,7 +3407,7 @@ Important: Run "make" to regenerate code after modifying this file
false - rules + rules []object
@@ -6947,8 +3417,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index] -[↩ Parent](#rulegroupstatussubgroupsindex) +### RuleGroup.spec.subgroups[index].rules[index] +[↩ Parent](#rulegroupspecsubgroupsindex) @@ -6980,7 +3450,7 @@ Important: Run "make" to regenerate code after modifying this file
false - block + block object
@@ -6994,56 +3464,56 @@ Important: Run "make" to regenerate code after modifying this file
false - extract + extract object
false - extractTimestamp + extractTimestamp object
false - jsonExtract + jsonExtract object
false - jsonStringify + jsonStringify object
false - parse + parse object
false - parseJsonField + parseJsonField object
false - removeFields + removeFields object
false - replace + replace object
@@ -7053,8 +3523,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].block -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].block +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7105,8 +3575,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].extract -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].extract +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7139,8 +3609,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].extractTimestamp -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].extractTimestamp +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7182,8 +3652,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].jsonExtract -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].jsonExtract +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7218,8 +3688,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].jsonStringify -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].jsonStringify +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7261,8 +3731,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].parse -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].parse +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7302,8 +3772,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].parseJsonField -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].parseJsonField +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7350,8 +3820,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].removeFields -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].removeFields +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7377,8 +3847,8 @@ Important: Run "make" to regenerate code after modifying this file
-### RuleGroup.status.subgroups[index].rules[index].replace -[↩ Parent](#rulegroupstatussubgroupsindexrulesindex) +### RuleGroup.spec.subgroups[index].rules[index].replace +[↩ Parent](#rulegroupspecsubgroupsindexrulesindex) @@ -7423,3 +3893,31 @@ Important: Run "make" to regenerate code after modifying this file
true + + +### RuleGroup.status +[↩ Parent](#rulegroup) + + + +RuleGroupStatus defines the observed state of RuleGroup + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
idstring + INSERT ADDITIONAL STATUS FIELD - define observed state of cluster +Important: Run "make" to regenerate code after modifying this file
+
true
diff --git a/kuttl-test.yaml b/kuttl-test.yaml index b671fb0..e8f1855 100644 --- a/kuttl-test.yaml +++ b/kuttl-test.yaml @@ -1,11 +1,7 @@ apiVersion: kuttl.dev/v1beta1 kind: TestSuite testDirs: - - tests/integration/alerts - - tests/integration/rulegroups - - tests/integration/recordingrulegroupsets - tests/integration/prometheusrules - - tests/integration/outboundwebhooks - tests/integration/alertmangerconfigs namespace: default timeout: 60 diff --git a/tests/integration/alertmangerconfigs/alertmangerconfig-basic/02-assert.yaml b/tests/integration/alertmangerconfigs/alertmangerconfig-basic/02-assert.yaml index 4d945ee..2a33b36 100644 --- a/tests/integration/alertmangerconfigs/alertmangerconfig-basic/02-assert.yaml +++ b/tests/integration/alertmangerconfigs/alertmangerconfig-basic/02-assert.yaml @@ -14,11 +14,6 @@ spec: outboundWebhookType: opsgenie: url: https://api.opsgenie.com/ -status: - name: opsgenie-general.opsgenie.0 - outboundWebhookType: - opsgenie: - url: https://api.opsgenie.com/ --- apiVersion: coralogix.com/v1alpha1 @@ -37,11 +32,6 @@ spec: outboundWebhookType: slack: url: https://slack.com/api/chat.postMessage -status: - name: slack-default.slack.0 - outboundWebhookType: - slack: - url: https://slack.com/api/chat.postMessage --- apiVersion: coralogix.com/v1alpha1 @@ -56,11 +46,6 @@ metadata: kind: AlertmanagerConfig name: config-example spec: - name: slack-general.slack.0 - outboundWebhookType: - slack: - url: https://slack.com/api/chat.postMessage -status: name: slack-general.slack.0 outboundWebhookType: slack: diff --git a/tests/integration/alertmangerconfigs/alertmangerconfig-basic/03-assert.yaml b/tests/integration/alertmangerconfigs/alertmangerconfig-basic/03-assert.yaml index 75ca5a2..8bddc44 100644 --- a/tests/integration/alertmangerconfigs/alertmangerconfig-basic/03-assert.yaml +++ b/tests/integration/alertmangerconfigs/alertmangerconfig-basic/03-assert.yaml @@ -42,37 +42,6 @@ spec: - integrationName: slack-general.slack.0 retriggeringPeriodMinutes: 3 severity: Critical -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - labels: - severity: critical - slack_channel: '#observability' - name: app-latency - notificationGroups: - - groupByFields: - - alertname - - cluster - - alert_group - - job - - namespace - - severity - - priority - notifications: - - integrationName: slack-general.slack.0 - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 3 - severity: Critical --- apiVersion: coralogix.com/v1alpha1 @@ -125,45 +94,6 @@ spec: - integrationName: opsgenie-general.opsgenie.0 retriggeringPeriodMinutes: 2 severity: Info -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - labels: - opsgenie_team: team1 - severity: info - slack_channel: '#observability' - name: app-latency - notificationGroups: - - groupByFields: - - alertname - - cluster - - alert_group - - job - - namespace - - severity - - priority - notifications: - - integrationName: slack-general.slack.0 - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 3 - - groupByFields: - - coralogix.metadata.sdkId - notifications: - - integrationName: opsgenie-general.opsgenie.0 - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 2 - severity: Info - --- apiVersion: coralogix.com/v1alpha1 @@ -209,34 +139,3 @@ spec: # - integrationName: slack-default.slack.0 # retriggeringPeriodMinutes: 2 severity: Info -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - labels: - managed-by: coralogix-operator - name: app-latency -# notificationGroups: -# - groupByFields: -# - alertname -# - cluster -# - alert_group -# - job -# - namespace -# - severity -# - priority -# notifications: -# - integrationName: slack-default.slack.0 -# notifyOn: TriggeredOnly -# retriggeringPeriodMinutes: 2 - severity: Info - diff --git a/tests/integration/alertmangerconfigs/alertmangerconfig-basic/05-assert.yaml b/tests/integration/alertmangerconfigs/alertmangerconfig-basic/05-assert.yaml index cc006e2..cdf808d 100644 --- a/tests/integration/alertmangerconfigs/alertmangerconfig-basic/05-assert.yaml +++ b/tests/integration/alertmangerconfigs/alertmangerconfig-basic/05-assert.yaml @@ -42,37 +42,6 @@ spec: - integrationName: slack-general.slack.0 retriggeringPeriodMinutes: 4 severity: Critical -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - labels: - severity: critical - slack_channel: '#observability' - name: app-latency - notificationGroups: - - groupByFields: - - alertname - - cluster - - alert_group - - job - - namespace - - severity - - priority - notifications: - - integrationName: slack-general.slack.0 - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 4 - severity: Critical --- apiVersion: coralogix.com/v1alpha1 @@ -120,38 +89,6 @@ spec: - integrationName: slack-general.slack.0 retriggeringPeriodMinutes: 4 severity: Info -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - labels: - opsgenie_team: team1 - severity: info - slack_channel: '#observability' - name: app-latency - notificationGroups: - - groupByFields: - - alertname - - cluster - - alert_group - - job - - namespace - - severity - - priority - notifications: - - integrationName: slack-general.slack.0 - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 4 - severity: Info --- apiVersion: coralogix.com/v1alpha1 @@ -195,34 +132,3 @@ spec: - integrationName: slack-default.slack.0 retriggeringPeriodMinutes: 3 severity: Info -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - labels: - managed-by: coralogix-operator - name: app-latency - notificationGroups: - - groupByFields: - - alertname - - cluster - - alert_group - - job - - namespace - - severity - - priority - notifications: - - integrationName: slack-default.slack.0 - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 3 - severity: Info - diff --git a/tests/integration/prometheusrules/prometheusrules-basic/01-assert.yaml b/tests/integration/prometheusrules/prometheusrules-basic/01-assert.yaml index 5fbf14b..4ba1b33 100644 --- a/tests/integration/prometheusrules/prometheusrules-basic/01-assert.yaml +++ b/tests/integration/prometheusrules/prometheusrules-basic/01-assert.yaml @@ -11,22 +11,3 @@ metadata: - apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule name: prometheus-example-rules -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - name: app-latency - notificationGroups: - - notifications: - - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 5 - severity: Critical diff --git a/tests/integration/prometheusrules/prometheusrules-basic/02-assert.yaml b/tests/integration/prometheusrules/prometheusrules-basic/02-assert.yaml index 8831b08..7ec60b9 100644 --- a/tests/integration/prometheusrules/prometheusrules-basic/02-assert.yaml +++ b/tests/integration/prometheusrules/prometheusrules-basic/02-assert.yaml @@ -11,22 +11,3 @@ metadata: - apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule name: prometheus-example-rules -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - name: app-latency - notificationGroups: - - notifications: - - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 5 - severity: Info diff --git a/tests/integration/prometheusrules/prometheusrules-basic/04-assert.yaml b/tests/integration/prometheusrules/prometheusrules-basic/04-assert.yaml index d302118..0f8a1b1 100644 --- a/tests/integration/prometheusrules/prometheusrules-basic/04-assert.yaml +++ b/tests/integration/prometheusrules/prometheusrules-basic/04-assert.yaml @@ -11,22 +11,3 @@ metadata: - apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule name: prometheus-example-rules -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FifteenMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - name: updated-app-latency - notificationGroups: - - notifications: - - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 15 - severity: Info diff --git a/tests/integration/prometheusrules/prometheusrules-basic/05-assert.yaml b/tests/integration/prometheusrules/prometheusrules-basic/05-assert.yaml index 8c32c36..1c8cbcb 100644 --- a/tests/integration/prometheusrules/prometheusrules-basic/05-assert.yaml +++ b/tests/integration/prometheusrules/prometheusrules-basic/05-assert.yaml @@ -11,22 +11,3 @@ metadata: - apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule name: prometheus-example-rules -status: - active: true - alertType: - metric: - promql: - conditions: - alertWhen: More - minNonNullValuesPercentage: 0 - sampleThresholdPercentage: 100 - threshold: "0" - timeWindow: FiveMinutes - searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) - by (le, destination_workload)) > 0.2 - name: updated-app-latency - notificationGroups: - - notifications: - - notifyOn: TriggeredOnly - retriggeringPeriodMinutes: 5 - severity: Critical