Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
🚑 Don't add "db down" rule if no Postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
grdryn committed Dec 11, 2019
1 parent f8b3254 commit 858665f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

## [0.4.1] - 2019-12-11
### Fixed
- UnifiedPushDatabaseDown alert always fired if using external database

## [0.4.0] - 2019-12-03
### Added
- UnifiedpushServer CRs can contain coordinates for an external PostgreSQL database
Expand Down
26 changes: 16 additions & 10 deletions pkg/controller/unifiedpushserver/unifiedpushserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,6 @@ func reconcilePrometheusRule(prometheusRule *monitoringv1.PrometheusRule, cr *pu
Labels: critical,
Annotations: unifiedPushConsoleDownAnnotations,
},
{
Alert: "UnifiedPushDatabaseDown",
Expr: intstr.IntOrString{
Type: intstr.String,
StrVal: fmt.Sprintf("absent(kube_pod_container_status_running{namespace=\"%s\",container=\"postgresql\"} == 1)", namespace),
},
For: "5m",
Labels: critical,
Annotations: unifiedPushDatabaseDownAnnotations,
},
{
Alert: "UnifiedPushJavaHeapThresholdExceeded",
Expr: intstr.IntOrString{
Expand Down Expand Up @@ -471,6 +461,22 @@ func reconcilePrometheusRule(prometheusRule *monitoringv1.PrometheusRule, cr *pu
},
},
}

// Don't add UnifiedPushDatabaseDown rule if there's no Postgresql
if !cr.Spec.ExternalDB {
rule := monitoringv1.Rule{
Alert: "UnifiedPushDatabaseDown",
Expr: intstr.IntOrString{
Type: intstr.String,
StrVal: fmt.Sprintf("absent(kube_pod_container_status_running{namespace=\"%s\",container=\"postgresql\"} == 1)", namespace),
},
For: "5m",
Labels: critical,
Annotations: unifiedPushDatabaseDownAnnotations,
}

prometheusRule.Spec.Groups[0].Rules = append(prometheusRule.Spec.Groups[0].Rules, rule)
}
}

func reconcileServiceMonitor(serviceMonitor *monitoringv1.ServiceMonitor) {
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package version

var (
Version = "0.4.0"
Version = "0.4.1"
)

0 comments on commit 858665f

Please sign in to comment.