diff --git a/api/v1beta1/grafanaalertrulegroup_types.go b/api/v1beta1/grafanaalertrulegroup_types.go
index 69c5b60c1..2fc1ec71d 100644
--- a/api/v1beta1/grafanaalertrulegroup_types.go
+++ b/api/v1beta1/grafanaalertrulegroup_types.go
@@ -75,6 +75,8 @@ type AlertRule struct {
IsPaused bool `json:"isPaused,omitempty"`
+ NotificationSettings *NotificationSettings `json:"notificationSettings,omitempty"`
+
Labels map[string]string `json:"labels,omitempty"`
// +kubebuilder:validation:Enum=Alerting;NoData;OK;KeepLast
@@ -89,6 +91,15 @@ type AlertRule struct {
UID string `json:"uid"`
}
+type NotificationSettings struct {
+ GroupBy []string `json:"group_by,omitempty"`
+ GroupInterval string `json:"group_interval,omitempty"`
+ GroupWait string `json:"group_wait,omitempty"`
+ Receiver string `json:"receiver"`
+ MuteTimeIntervals []string `json:"mute_time_intervals,omitempty"`
+ RepeatInterval string `json:"repeat_interval,omitempty"`
+}
+
type AlertQuery struct {
// Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.
DatasourceUID string `json:"datasourceUid,omitempty"`
diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go
index 7782a3533..f8036cb5f 100644
--- a/api/v1beta1/zz_generated.deepcopy.go
+++ b/api/v1beta1/zz_generated.deepcopy.go
@@ -83,6 +83,11 @@ func (in *AlertRule) DeepCopyInto(out *AlertRule) {
*out = new(metav1.Duration)
**out = **in
}
+ if in.NotificationSettings != nil {
+ in, out := &in.NotificationSettings, &out.NotificationSettings
+ *out = new(NotificationSettings)
+ (*in).DeepCopyInto(*out)
+ }
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
@@ -1447,6 +1452,31 @@ func (in NamespacedResourceList) DeepCopy() NamespacedResourceList {
return *out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *NotificationSettings) DeepCopyInto(out *NotificationSettings) {
+ *out = *in
+ if in.GroupBy != nil {
+ in, out := &in.GroupBy, &out.GroupBy
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.MuteTimeIntervals != nil {
+ in, out := &in.MuteTimeIntervals, &out.MuteTimeIntervals
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationSettings.
+func (in *NotificationSettings) DeepCopy() *NotificationSettings {
+ if in == nil {
+ return nil
+ }
+ out := new(NotificationSettings)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ObjectMeta) DeepCopyInto(out *ObjectMeta) {
*out = *in
diff --git a/config/crd/bases/grafana.integreatly.org_grafanaalertrulegroups.yaml b/config/crd/bases/grafana.integreatly.org_grafanaalertrulegroups.yaml
index 270fee076..515bd1696 100644
--- a/config/crd/bases/grafana.integreatly.org_grafanaalertrulegroups.yaml
+++ b/config/crd/bases/grafana.integreatly.org_grafanaalertrulegroups.yaml
@@ -125,6 +125,27 @@ spec:
- OK
- KeepLast
type: string
+ notificationSettings:
+ properties:
+ group_by:
+ items:
+ type: string
+ type: array
+ group_interval:
+ type: string
+ group_wait:
+ type: string
+ mute_time_intervals:
+ items:
+ type: string
+ type: array
+ receiver:
+ type: string
+ repeat_interval:
+ type: string
+ required:
+ - receiver
+ type: object
title:
example: Always firing
maxLength: 190
diff --git a/config/grafana.integreatly.org_grafanaalertrulegroups.yaml b/config/grafana.integreatly.org_grafanaalertrulegroups.yaml
index 70551ce04..e4b679529 100644
--- a/config/grafana.integreatly.org_grafanaalertrulegroups.yaml
+++ b/config/grafana.integreatly.org_grafanaalertrulegroups.yaml
@@ -178,6 +178,27 @@ spec:
- OK
- KeepLast
type: string
+ notificationSettings:
+ properties:
+ group_by:
+ items:
+ type: string
+ type: array
+ group_interval:
+ type: string
+ group_wait:
+ type: string
+ mute_time_intervals:
+ items:
+ type: string
+ type: array
+ receiver:
+ type: string
+ repeat_interval:
+ type: string
+ required:
+ - receiver
+ type: object
title:
example: Always firing
maxLength: 190
diff --git a/controllers/dashboard_controller.go b/controllers/dashboard_controller.go
index 0d20ac1e8..1bd4b4669 100644
--- a/controllers/dashboard_controller.go
+++ b/controllers/dashboard_controller.go
@@ -490,9 +490,6 @@ func (r *GrafanaDashboardReconciler) fetchDashboardJson(ctx context.Context, das
func (r *GrafanaDashboardReconciler) getDashboardEnvs(ctx context.Context, dashboard *v1beta1.GrafanaDashboard) (map[string]string, error) {
envs := make(map[string]string)
- if dashboard.Spec.EnvsFrom == nil && dashboard.Spec.Envs == nil {
- return nil, fmt.Errorf("dashboard.Spec.Envs or dashboard.Spec.EnvFrom nil, can't get envs for dashboard: %s", dashboard.Name)
- }
if dashboard.Spec.EnvsFrom != nil {
for _, ref := range dashboard.Spec.EnvsFrom {
key, val, err := r.getReferencedValue(ctx, dashboard, ref)
diff --git a/controllers/grafanaalertrulegroup_controller.go b/controllers/grafanaalertrulegroup_controller.go
index ad401b1d2..9db2c0b08 100644
--- a/controllers/grafanaalertrulegroup_controller.go
+++ b/controllers/grafanaalertrulegroup_controller.go
@@ -225,6 +225,15 @@ func (r *GrafanaAlertRuleGroupReconciler) reconcileWithInstance(ctx context.Cont
Title: &rule.Title,
UID: rule.UID,
}
+ if rule.NotificationSettings != nil {
+ apiRule.NotificationSettings = &models.AlertRuleNotificationSettings{
+ Receiver: &rule.NotificationSettings.Receiver,
+ GroupBy: rule.NotificationSettings.GroupBy,
+ GroupWait: rule.NotificationSettings.GroupWait,
+ GroupInterval: rule.NotificationSettings.GroupInterval,
+ RepeatInterval: rule.NotificationSettings.RepeatInterval,
+ }
+ }
for idx, q := range rule.Data {
apiRule.Data[idx] = &models.AlertQuery{
DatasourceUID: q.DatasourceUID,
diff --git a/deploy/helm/grafana-operator/crds/grafana.integreatly.org_grafanaalertrulegroups.yaml b/deploy/helm/grafana-operator/crds/grafana.integreatly.org_grafanaalertrulegroups.yaml
index 270fee076..515bd1696 100644
--- a/deploy/helm/grafana-operator/crds/grafana.integreatly.org_grafanaalertrulegroups.yaml
+++ b/deploy/helm/grafana-operator/crds/grafana.integreatly.org_grafanaalertrulegroups.yaml
@@ -125,6 +125,27 @@ spec:
- OK
- KeepLast
type: string
+ notificationSettings:
+ properties:
+ group_by:
+ items:
+ type: string
+ type: array
+ group_interval:
+ type: string
+ group_wait:
+ type: string
+ mute_time_intervals:
+ items:
+ type: string
+ type: array
+ receiver:
+ type: string
+ repeat_interval:
+ type: string
+ required:
+ - receiver
+ type: object
title:
example: Always firing
maxLength: 190
diff --git a/deploy/kustomize/base/crds.yaml b/deploy/kustomize/base/crds.yaml
index 03d9dff91..37543db3d 100644
--- a/deploy/kustomize/base/crds.yaml
+++ b/deploy/kustomize/base/crds.yaml
@@ -124,6 +124,27 @@ spec:
- OK
- KeepLast
type: string
+ notificationSettings:
+ properties:
+ group_by:
+ items:
+ type: string
+ type: array
+ group_interval:
+ type: string
+ group_wait:
+ type: string
+ mute_time_intervals:
+ items:
+ type: string
+ type: array
+ receiver:
+ type: string
+ repeat_interval:
+ type: string
+ required:
+ - receiver
+ type: object
title:
example: Always firing
maxLength: 190
diff --git a/docs/docs/api.md b/docs/docs/api.md
index 90a478dd0..fd36fe0c8 100644
--- a/docs/docs/api.md
+++ b/docs/docs/api.md
@@ -333,6 +333,13 @@ AlertRule defines a specific rule to be evaluated. It is based on the upstream m
Name | +Type | +Description | +Required | +
---|---|---|---|
receiver | +string | +
+ + |
+ true | +
group_by | +[]string | +
+ + |
+ false | +
group_interval | +string | +
+ + |
+ false | +
group_wait | +string | +
+ + |
+ false | +
mute_time_intervals | +[]string | +
+ + |
+ false | +
repeat_interval | +string | +
+ + |
+ false | +