diff --git a/dev/managedservicesplatform/operationdocs/diagram/diagram.go b/dev/managedservicesplatform/operationdocs/diagram/diagram.go index 6056dcae305..8e5ddae611d 100644 --- a/dev/managedservicesplatform/operationdocs/diagram/diagram.go +++ b/dev/managedservicesplatform/operationdocs/diagram/diagram.go @@ -119,7 +119,7 @@ func (d *diagram) Generate(s *spec.Spec, e string) error { return errors.Wrap(err, "failed to add connection from cloudrun to monitoring") } - if env.Category != spec.EnvironmentCategoryTest && env.Alerting != nil && pointers.DerefZero(env.Alerting.Opsgenie) { + if env.Alerting.ShouldEnableOpsgenie(env.Category.IsProduction()) { var opsgenieNode string graph, opsgenieNode, err = newOpsgenieNode(graph) if err != nil { diff --git a/dev/managedservicesplatform/spec/environment.go b/dev/managedservicesplatform/spec/environment.go index 375c048d36a..eb2faf3af2f 100644 --- a/dev/managedservicesplatform/spec/environment.go +++ b/dev/managedservicesplatform/spec/environment.go @@ -1055,3 +1055,11 @@ func (s EnvironmentLocationsSpec) Validate() []error { return errs } + +// ShouldEnableOpsgenie returns env.alerting.opsgenie or falls back to isProduction is the former is nil +func (s *EnvironmentAlertingSpec) ShouldEnableOpsgenie(isProduction bool) bool { + if s == nil || s.Opsgenie == nil { + return isProduction + } + return *s.Opsgenie +} diff --git a/dev/managedservicesplatform/stacks/monitoring/monitoring.go b/dev/managedservicesplatform/stacks/monitoring/monitoring.go index c68a656fcb5..109ffe82329 100644 --- a/dev/managedservicesplatform/stacks/monitoring/monitoring.go +++ b/dev/managedservicesplatform/stacks/monitoring/monitoring.go @@ -206,10 +206,10 @@ func NewStack(stacks *stack.Set, vars Variables) (*CrossStackOutput, error) { // Let the team own the integration. OwnerTeamId: team.Id(), - // Supress all notifications if Alerting.Opsgenie is false - - // this allows us to see the alerts, but not necessarily get - // paged by it. - SuppressNotifications: !pointers.DerefZero(vars.Alerting.Opsgenie), + // Supress all notifications if Alerting.Opsgenie is explcitly set to false or + // if Alerting.Opsgenie is nil suppress notifications if this is not a production environment. + // This allows us to see the alerts, but not necessarily get paged by it. + SuppressNotifications: !vars.Alerting.ShouldEnableOpsgenie(vars.EnvironmentCategory.IsProduction()), // Point alerts sent through this integration at the Opsgenie team. Responders: []*opsgenieintegration.ApiIntegrationResponders{{