Skip to content

Commit

Permalink
Add default label of uid for service
Browse files Browse the repository at this point in the history
  • Loading branch information
liangyuanpeng committed Feb 19, 2022
1 parent 929f4ac commit ad9d336
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/store/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
descServiceAnnotationsHelp = "Kubernetes annotations converted to Prometheus labels."
descServiceLabelsName = "kube_service_labels"
descServiceLabelsHelp = "Kubernetes labels converted to Prometheus labels."
descServiceLabelsDefaultLabels = []string{"namespace", "service"}
descServiceLabelsDefaultLabels = []string{"namespace", "service", "uid"}
)

func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
Expand Down Expand Up @@ -180,7 +180,7 @@ func wrapSvcFunc(f func(*v1.Service) *metric.Family) func(interface{}) *metric.F
metricFamily := f(svc)

for _, m := range metricFamily.Metrics {
m.LabelKeys, m.LabelValues = mergeKeyValues(descServiceLabelsDefaultLabels, []string{svc.Namespace, svc.Name}, m.LabelKeys, m.LabelValues)
m.LabelKeys, m.LabelValues = mergeKeyValues(descServiceLabelsDefaultLabels, []string{svc.Namespace, svc.Name, string(svc.UID)}, m.LabelKeys, m.LabelValues)
}

return metricFamily
Expand Down

0 comments on commit ad9d336

Please sign in to comment.