diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6deb00d..cbd0edea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * A gRPC server that listens for SSF spans and dogstatsd metrics on grpc_listening_addresses. Thanks [eriwo-stripe](https://github.com/eriwo-stripe) and [shrivu-stripe](https://github.com/shrivu-stripe)! * The ability to emit metrics from veneur-emit via the gRPC protocol as well as the option to specify a proxy for those metrics. Thanks [eriwo-stripe](https://github.com/eriwo-stripe) and [shrivu-stripe](https://github.com/shrivu-stripe)! * The "veneur.listen.received_per_protocol_total" metric to be published by global Veneur instances. This is a counter to track the metrics being directly listened for (rather than imported) by protocol. Thanks, [eriwo-stripe](https://github.com/eriwo-stripe)! +* A fix for forwarding metrics with gRPC using the kubernetes discoverer. Thanks, [androohan](https://github.com/androohan)! # 14.0.0, 2020-01-14 diff --git a/kubernetes.go b/kubernetes.go index f27e4683c..5c229950a 100644 --- a/kubernetes.go +++ b/kubernetes.go @@ -50,6 +50,12 @@ func (kd *KubernetesDiscoverer) GetDestinationsForService(serviceName string) ([ if len(pod.Spec.Containers) > 0 { for _, container := range pod.Spec.Containers { for _, port := range container.Ports { + if port.Name == "grpc" { + forwardPort = strconv.Itoa(int(port.ContainerPort)) + log.WithField("port", forwardPort).Debug("Found grpc port") + break + } + if port.Name == "http" { forwardPort = strconv.Itoa(int(port.ContainerPort)) log.WithField("port", forwardPort).Debug("Found http port") @@ -83,8 +89,7 @@ func (kd *KubernetesDiscoverer) GetDestinationsForService(serviceName string) ([ continue } - // prepend with // so that it is a valid URL parseable by url.Parse - podIp := fmt.Sprintf("http://%s:%s", pod.Status.PodIP, forwardPort) + podIp := fmt.Sprintf("%s:%s", pod.Status.PodIP, forwardPort) ips = append(ips, podIp) } return ips, nil