Skip to content

Commit 2c6d400

Browse files
Label "app.kubernetes.io/instance" in the Prometheus metric (bitnami-labs#1620)
Re-creating bitnami-labs#1579 Signed-off-by: tewfik-ghariani <[email protected]>
1 parent 65f58f9 commit 2c6d400

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pkg/controller/metrics.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const (
1717
labelNamespace = "namespace"
1818
labelName = "name"
1919
labelCondition = "condition"
20+
labelInstance = "ss_app_kubernetes_io_instance"
2021
)
2122

2223
var conditionStatusToGaugeValue = map[v1.ConditionStatus]float64{
@@ -47,11 +48,14 @@ var (
4748
[]string{"reason", "namespace"},
4849
)
4950

50-
conditionInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
51-
Namespace: metricNamespace,
52-
Name: "condition_info",
53-
Help: "Current SealedSecret condition status. Values are -1 (false), 0 (unknown or absent), 1 (true)",
54-
}, []string{labelNamespace, labelName, labelCondition})
51+
conditionInfo = prometheus.NewGaugeVec(
52+
prometheus.GaugeOpts{
53+
Namespace: metricNamespace,
54+
Name: "condition_info",
55+
Help: "Current SealedSecret condition status. Values are -1 (false), 0 (unknown or absent), 1 (true)",
56+
},
57+
[]string{labelNamespace, labelName, labelCondition, labelInstance},
58+
)
5559

5660
httpRequestsTotal = prometheus.NewCounterVec(
5761
prometheus.CounterOpts{
@@ -102,6 +106,7 @@ func ObserveCondition(ssecret *v1alpha1.SealedSecret) {
102106
labelNamespace: ssecret.Namespace,
103107
labelName: ssecret.Name,
104108
labelCondition: string(condition.Type),
109+
labelInstance: ssecret.Labels["app.kubernetes.io/instance"],
105110
}).Set(conditionStatusToGaugeValue[condition.Status])
106111
}
107112
}
@@ -112,7 +117,7 @@ func UnregisterCondition(ssecret *v1alpha1.SealedSecret) {
112117
return
113118
}
114119
for _, condition := range ssecret.Status.Conditions {
115-
conditionInfo.MetricVec.DeleteLabelValues(ssecret.Namespace, ssecret.Name, string(condition.Type))
120+
conditionInfo.MetricVec.DeleteLabelValues(ssecret.Namespace, ssecret.Name, string(condition.Type), labelInstance)
116121
}
117122
}
118123

0 commit comments

Comments
 (0)