From 0ac7e7217e28dd165787b80219f6085c8d97f814 Mon Sep 17 00:00:00 2001 From: Florian Pfitzer Date: Tue, 16 Jun 2015 17:29:45 +0200 Subject: [PATCH] Use Consul ServiceAddress instead of Address when set --- retrieval/discovery/consul.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/retrieval/discovery/consul.go b/retrieval/discovery/consul.go index 768c22b89..01299af8e 100644 --- a/retrieval/discovery/consul.go +++ b/retrieval/discovery/consul.go @@ -258,6 +258,10 @@ func (cd *ConsulDiscovery) watchService(srv *consulService, ch chan<- *config.Ta for _, node := range nodes { addr := fmt.Sprintf("%s:%d", node.Address, node.ServicePort) + // Use ServiceAddress instead of Address if not empty. + if len(node.ServiceAddress) > 0 { + addr = fmt.Sprintf("%s:%d", node.ServiceAddress, node.ServicePort) + } // We surround the separated list with the separator as well. This way regular expressions // in relabeling rules don't have to consider tag positions. tags := cd.tagSeparator + strings.Join(node.ServiceTags, cd.tagSeparator) + cd.tagSeparator