lib/promscrape/discovery/dns: add __meta_dns_srv_record_target and __meta_dns_srv_record_port labels

This syncs dns service discovery with Prometheus 2.21 - see https://github.com/prometheus/prometheus/releases
and https://github.com/prometheus/prometheus/pull/7678 .
This commit is contained in:
Aliaksandr Valialkin 2020-09-11 21:34:13 +03:00
parent 6ad6480400
commit 0e19f35af5
2 changed files with 6 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"strconv"
"strings"
"time"
@ -124,6 +125,8 @@ func appendAddrLabels(ms []map[string]string, name, target string, port int) []m
m := map[string]string{
"__address__": addr,
"__meta_dns_name": name,
"__meta_dns_srv_record_target": target,
"__meta_dns_srv_record_port": strconv.Itoa(port),
}
return append(ms, m)
}

View file

@ -160,7 +160,7 @@ func getEndpointSliceLabels(eps *EndpointSlice, addr string, ea Endpoint, epp En
"__meta_kubernetes_endpointslice_endpoint_conditions_ready": strconv.FormatBool(ea.Conditions.Ready),
"__meta_kubernetes_endpointslice_port_name": epp.Name,
"__meta_kubernetes_endpointslice_port_protocol": epp.Protocol,
"__meta_kubernetes_endpointslice_port": strconv.FormatUint(uint64(epp.Port), 10),
"__meta_kubernetes_endpointslice_port": strconv.Itoa(epp.Port),
}
if epp.AppProtocol != "" {
m["__meta_kubernetes_endpointslice_port_app_protocol"] = epp.AppProtocol