mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Map target infos of endpoints to prometheus meta labels. (#3770)
This commit is contained in:
parent
bf7d87aed2
commit
56ed29fbf7
|
@ -178,10 +178,12 @@ func endpointsSource(ep *apiv1.Endpoints) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
endpointsNameLabel = metaLabelPrefix + "endpoints_name"
|
endpointsNameLabel = metaLabelPrefix + "endpoints_name"
|
||||||
endpointReadyLabel = metaLabelPrefix + "endpoint_ready"
|
endpointReadyLabel = metaLabelPrefix + "endpoint_ready"
|
||||||
endpointPortNameLabel = metaLabelPrefix + "endpoint_port_name"
|
endpointPortNameLabel = metaLabelPrefix + "endpoint_port_name"
|
||||||
endpointPortProtocolLabel = metaLabelPrefix + "endpoint_port_protocol"
|
endpointPortProtocolLabel = metaLabelPrefix + "endpoint_port_protocol"
|
||||||
|
endpointAddressTargetKindLabel = metaLabelPrefix + "endpoint_address_target_kind"
|
||||||
|
endpointAddressTargetNameLabel = metaLabelPrefix + "endpoint_address_target_name"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *Endpoints) buildEndpoints(eps *apiv1.Endpoints) *targetgroup.Group {
|
func (e *Endpoints) buildEndpoints(eps *apiv1.Endpoints) *targetgroup.Group {
|
||||||
|
@ -210,6 +212,11 @@ func (e *Endpoints) buildEndpoints(eps *apiv1.Endpoints) *targetgroup.Group {
|
||||||
endpointReadyLabel: lv(ready),
|
endpointReadyLabel: lv(ready),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if addr.TargetRef != nil {
|
||||||
|
target[model.LabelName(endpointAddressTargetKindLabel)] = lv(addr.TargetRef.Kind)
|
||||||
|
target[model.LabelName(endpointAddressTargetNameLabel)] = lv(addr.TargetRef.Name)
|
||||||
|
}
|
||||||
|
|
||||||
pod := e.resolvePodRef(addr.TargetRef)
|
pod := e.resolvePodRef(addr.TargetRef)
|
||||||
if pod == nil {
|
if pod == nil {
|
||||||
// This target is not a Pod, so don't continue with Pod specific logic.
|
// This target is not a Pod, so don't continue with Pod specific logic.
|
||||||
|
|
|
@ -199,20 +199,22 @@ func TestEndpointsDiscoveryAdd(t *testing.T) {
|
||||||
{
|
{
|
||||||
Targets: []model.LabelSet{
|
Targets: []model.LabelSet{
|
||||||
{
|
{
|
||||||
"__address__": "4.3.2.1:9000",
|
"__address__": "4.3.2.1:9000",
|
||||||
"__meta_kubernetes_endpoint_port_name": "testport",
|
"__meta_kubernetes_endpoint_port_name": "testport",
|
||||||
"__meta_kubernetes_endpoint_port_protocol": "TCP",
|
"__meta_kubernetes_endpoint_port_protocol": "TCP",
|
||||||
"__meta_kubernetes_endpoint_ready": "true",
|
"__meta_kubernetes_endpoint_ready": "true",
|
||||||
"__meta_kubernetes_pod_name": "testpod",
|
"__meta_kubernetes_endpoint_address_target_kind": "Pod",
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_endpoint_address_target_name": "testpod",
|
||||||
"__meta_kubernetes_pod_ready": "unknown",
|
"__meta_kubernetes_pod_name": "testpod",
|
||||||
"__meta_kubernetes_pod_node_name": "testnode",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_ready": "unknown",
|
||||||
"__meta_kubernetes_pod_container_name": "c1",
|
"__meta_kubernetes_pod_node_name": "testnode",
|
||||||
"__meta_kubernetes_pod_container_port_name": "mainport",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_container_port_number": "9000",
|
"__meta_kubernetes_pod_container_name": "c1",
|
||||||
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
"__meta_kubernetes_pod_container_port_name": "mainport",
|
||||||
"__meta_kubernetes_pod_uid": "deadbeef",
|
"__meta_kubernetes_pod_container_port_number": "9000",
|
||||||
|
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
||||||
|
"__meta_kubernetes_pod_uid": "deadbeef",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__address__": "1.2.3.4:9001",
|
"__address__": "1.2.3.4:9001",
|
||||||
|
|
|
@ -670,6 +670,8 @@ Available meta labels:
|
||||||
* `__meta_kubernetes_endpoint_ready`: Set to `true` or `false` for the endpoint's ready state.
|
* `__meta_kubernetes_endpoint_ready`: Set to `true` or `false` for the endpoint's ready state.
|
||||||
* `__meta_kubernetes_endpoint_port_name`: Name of the endpoint port.
|
* `__meta_kubernetes_endpoint_port_name`: Name of the endpoint port.
|
||||||
* `__meta_kubernetes_endpoint_port_protocol`: Protocol of the endpoint port.
|
* `__meta_kubernetes_endpoint_port_protocol`: Protocol of the endpoint port.
|
||||||
|
* `__meta_kubernetes_endpoint_address_target_kind`: Kind of the endpoint address target.
|
||||||
|
* `__meta_kubernetes_endpoint_address_target_name`: Name of the endpoint address target.
|
||||||
* If the endpoints belong to a service, all labels of the `role: service` discovery are attached.
|
* If the endpoints belong to a service, all labels of the `role: service` discovery are attached.
|
||||||
* For all targets backed by a pod, all labels of the `role: pod` discovery are attached.
|
* For all targets backed by a pod, all labels of the `role: pod` discovery are attached.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue