Skip to content

Commit

Permalink
feat: Add app.kubernetes.io/instance label to the condition_info Prom…
Browse files Browse the repository at this point in the history
…etheus metric

Signed-off-by: tewfik-ghariani <[email protected]>
  • Loading branch information
tewfik-ghariani committed Oct 28, 2024
1 parent e57d956 commit a8d42fd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/controller/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
labelNamespace = "namespace"
labelName = "name"
labelCondition = "condition"
labelInstance = "ss_app_kubernetes_io_instance"
)

var conditionStatusToGaugeValue = map[v1.ConditionStatus]float64{
Expand Down Expand Up @@ -47,11 +48,14 @@ var (
[]string{"reason", "namespace"},
)

conditionInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricNamespace,
Name: "condition_info",
Help: "Current SealedSecret condition status. Values are -1 (false), 0 (unknown or absent), 1 (true)",
}, []string{labelNamespace, labelName, labelCondition})
conditionInfo = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: metricNamespace,
Name: "condition_info",
Help: "Current SealedSecret condition status. Values are -1 (false), 0 (unknown or absent), 1 (true)",
},
[]string{labelNamespace, labelName, labelCondition, labelInstance},
)

httpRequestsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand Down Expand Up @@ -102,6 +106,7 @@ func ObserveCondition(ssecret *v1alpha1.SealedSecret) {
labelNamespace: ssecret.Namespace,
labelName: ssecret.Name,
labelCondition: string(condition.Type),
labelInstance: ssecret.Labels["app.kubernetes.io/instance"],
}).Set(conditionStatusToGaugeValue[condition.Status])
}
}
Expand All @@ -112,7 +117,7 @@ func UnregisterCondition(ssecret *v1alpha1.SealedSecret) {
return
}
for _, condition := range ssecret.Status.Conditions {
conditionInfo.MetricVec.DeleteLabelValues(ssecret.Namespace, ssecret.Name, string(condition.Type))
conditionInfo.MetricVec.DeleteLabelValues(ssecret.Namespace, ssecret.Name, string(condition.Type), labelInstance)
}
}

Expand Down

0 comments on commit a8d42fd

Please sign in to comment.