mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
add __meta_kubernetes_service_port_number (#10945)
Signed-off-by: yngwiewang <yngwiewang@163.com>
This commit is contained in:
parent
44fcf876ca
commit
1abbf5a5c5
|
@ -150,6 +150,7 @@ const (
|
|||
serviceAnnotationPrefix = metaLabelPrefix + "service_annotation_"
|
||||
serviceAnnotationPresentPrefix = metaLabelPrefix + "service_annotationpresent_"
|
||||
servicePortNameLabel = metaLabelPrefix + "service_port_name"
|
||||
servicePortNumberLabel = metaLabelPrefix + "service_port_number"
|
||||
servicePortProtocolLabel = metaLabelPrefix + "service_port_protocol"
|
||||
serviceClusterIPLabel = metaLabelPrefix + "service_cluster_ip"
|
||||
serviceExternalNameLabel = metaLabelPrefix + "service_external_name"
|
||||
|
@ -189,6 +190,7 @@ func (s *Service) buildService(svc *apiv1.Service) *targetgroup.Group {
|
|||
labelSet := model.LabelSet{
|
||||
model.AddressLabel: lv(addr),
|
||||
servicePortNameLabel: lv(port.Name),
|
||||
servicePortNumberLabel: lv(strconv.FormatInt(int64(port.Port), 10)),
|
||||
servicePortProtocolLabel: lv(string(port.Protocol)),
|
||||
serviceType: lv(string(svc.Spec.Type)),
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ func TestServiceDiscoveryAdd(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
@ -132,6 +133,7 @@ func TestServiceDiscoveryAdd(t *testing.T) {
|
|||
"__address__": "testservice-external.default.svc:31900",
|
||||
"__meta_kubernetes_service_type": "ExternalName",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "31900",
|
||||
"__meta_kubernetes_service_external_name": "FooExternalName",
|
||||
},
|
||||
},
|
||||
|
@ -182,6 +184,7 @@ func TestServiceDiscoveryUpdate(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport0",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
{
|
||||
"__meta_kubernetes_service_port_protocol": "UDP",
|
||||
|
@ -189,6 +192,7 @@ func TestServiceDiscoveryUpdate(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport1",
|
||||
"__meta_kubernetes_service_port_number": "30901",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
@ -227,6 +231,7 @@ func TestServiceDiscoveryNamespaces(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
@ -243,6 +248,7 @@ func TestServiceDiscoveryNamespaces(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
@ -277,6 +283,7 @@ func TestServiceDiscoveryOwnNamespace(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
@ -311,6 +318,7 @@ func TestServiceDiscoveryAllNamespaces(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
@ -327,6 +335,7 @@ func TestServiceDiscoveryAllNamespaces(t *testing.T) {
|
|||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_port_number": "30900",
|
||||
},
|
||||
},
|
||||
Labels: model.LabelSet{
|
||||
|
|
Loading…
Reference in a new issue