Skip to content

Commit

Permalink
Add statefulset invalid error metrics
Browse files Browse the repository at this point in the history
Signed-off-by: d-kuro <[email protected]>
  • Loading branch information
d-kuro committed Jul 13, 2022
1 parent 21a21ce commit b780310
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/mysqlcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,9 @@ func (r *MySQLClusterReconciler) reconcileV1StatefulSet(ctx context.Context, req
if needRecreate {
metrics.StatefulSetRecreateErrorTotal.WithLabelValues(cluster.Name, cluster.Namespace).Inc()
}
if apierrors.IsInvalid(err) {
metrics.StatefulSetInvalidErrorTotal.WithLabelValues(cluster.Name, cluster.Namespace).Inc()
}
return fmt.Errorf("failed to reconcile stateful set: %w", err)
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
VolumeResizedErrorTotal *prometheus.CounterVec
StatefulSetRecreateTotal *prometheus.CounterVec
StatefulSetRecreateErrorTotal *prometheus.CounterVec
StatefulSetInvalidErrorTotal *prometheus.CounterVec
)

// Backup related metrics
Expand Down Expand Up @@ -191,4 +192,12 @@ func Register(registry prometheus.Registerer) {
Help: "The number of failed StatefulSet recreates",
}, []string{"name", "namespace"})
registry.MustRegister(StatefulSetRecreateErrorTotal)

StatefulSetInvalidErrorTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: clusteringSubsystem,
Name: "statefulset_invalid_errors_total",
Help: "The number of invalid error was returned updating a StatefulSet",
}, []string{"name", "namespace"})
registry.MustRegister(StatefulSetInvalidErrorTotal)
}

0 comments on commit b780310

Please sign in to comment.