Skip to content

Commit

Permalink
More metrics and rules
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiorua committed Jun 10, 2023
1 parent 4fcd396 commit 10d84ff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/vals-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ kubeVersion: ">= 1.19.0-0"
type: application

# Chart version
version: 0.7.5-beta1
version: 0.7.5-beta2

# Latest container tag
appVersion: "v0.7.5-beta1"
appVersion: "v0.7.5-beta2"

maintainers:
- email: [email protected]
Expand Down
18 changes: 18 additions & 0 deletions charts/vals-operator/templates/prometheusrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
- alert: ValsOperatorDbSecretExpired
expr: time() > vals_operator_dbsecret_expire_time
for: 30m
labels:
severity: warning
{{- if .Values.prometheusRules.additionalRuleLabels }}
{{- with .Values.prometheusRules.additionalRuleLabels }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
annotations:
summary: vals-operator database secret expired
description: "Vals operator database credentials for {{`{{`}}$labels.secret{{`}}`}} in namespace {{`{{`}}$labels.namespace{{`}}`}} expired"
{{- if .Values.prometheusRules.additionalRuleAnnotations }}
{{- with .Values.prometheusRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
- alert: ValsOperatorSecretError
expr: vals_operator_secret_error > time() - 300
Expand Down
3 changes: 3 additions & 0 deletions controllers/dbsecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func (r *DbSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
if err := r.Update(context.Background(), &dbSecret); err != nil {
return ctrl.Result{}, err
}
/* mark as deleted in prom */
dmetrics.DbSecretExpireTime.WithLabelValues(dbSecret.Name, dbSecret.Namespace).Set(0)
dmetrics.DbSecretInfo.WithLabelValues(dbSecret.Name, dbSecret.Namespace).Set(0)
}

// Stop reconciliation as the item is being deleted
Expand Down
1 change: 1 addition & 0 deletions controllers/valssecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (r *ValsSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// Stop reconciliation as the item is being deleted
r.Log.Info(fmt.Sprintf("Secret %s deleted", secret.Name))
dmetrics.SecretInfo.WithLabelValues(secret.Name, secret.Namespace).Set(0)
return ctrl.Result{}, nil
}
//! [finalizer]
Expand Down

0 comments on commit 10d84ff

Please sign in to comment.