mirror of https://github.com/prometheus/prometheus
Merge pull request #8273 from fcddk/fcddk-k8s-enpoints-label
K8s SD: add endpoints labels metadatapull/8339/head
commit
19b0ec3baf
|
@ -15,6 +15,7 @@ package kubernetes
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/prometheus/prometheus/util/strutil"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
|
@ -199,6 +200,8 @@ func endpointsSourceFromNamespaceAndName(namespace, name string) string {
|
|||
}
|
||||
|
||||
const (
|
||||
endpointsLabelPrefix = metaLabelPrefix + "endpoints_label_"
|
||||
endpointsLabelPresentPrefix = metaLabelPrefix + "endpoints_labelpresent_"
|
||||
endpointsNameLabel = metaLabelPrefix + "endpoints_name"
|
||||
endpointNodeName = metaLabelPrefix + "endpoint_node_name"
|
||||
endpointHostname = metaLabelPrefix + "endpoint_hostname"
|
||||
|
@ -218,6 +221,12 @@ func (e *Endpoints) buildEndpoints(eps *apiv1.Endpoints) *targetgroup.Group {
|
|||
endpointsNameLabel: lv(eps.Name),
|
||||
}
|
||||
e.addServiceLabels(eps.Namespace, eps.Name, tg)
|
||||
//add endponits labels metadata
|
||||
for k, v := range eps.Labels {
|
||||
ln := strutil.SanitizeLabelName(k)
|
||||
tg.Labels[model.LabelName(endpointsLabelPrefix+ln)] = lv(v)
|
||||
tg.Labels[model.LabelName(endpointsLabelPresentPrefix+ln)] = presentValue
|
||||
}
|
||||
|
||||
type podEntry struct {
|
||||
pod *apiv1.Pod
|
||||
|
|
Loading…
Reference in New Issue