diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 2478cb65d0a..1133ae6bb03 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -375,6 +375,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Preliminary AIX support {pull}27954[27954] - Register additional name for `storage` metricset in the azure module. {pull}28447[28447] - Update reference to gosigar pacakge for filesystem windows fix. {pull}28909[28909] +- Override `Host()` on statsd MetricSet {pull}29103[29103] *Packetbeat* diff --git a/metricbeat/helper/server/udp/udp.go b/metricbeat/helper/server/udp/udp.go index e19f8697519..6bec8489b46 100644 --- a/metricbeat/helper/server/udp/udp.go +++ b/metricbeat/helper/server/udp/udp.go @@ -71,6 +71,10 @@ func NewUdpServer(base mb.BaseMetricSet) (server.Server, error) { }, nil } +func (g *UdpServer) GetHost() string { + return g.udpaddr.String() +} + func (g *UdpServer) Start() error { listener, err := net.ListenUDP("udp", g.udpaddr) if err != nil { diff --git a/x-pack/metricbeat/module/statsd/server/server.go b/x-pack/metricbeat/module/statsd/server/server.go index 3e9f35d8436..b9df691b6b8 100644 --- a/x-pack/metricbeat/module/statsd/server/server.go +++ b/x-pack/metricbeat/module/statsd/server/server.go @@ -104,6 +104,12 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { }, nil } +// Host returns the hostname or other module specific value that identifies a +// specific host or service instance from which to collect metrics. +func (b *MetricSet) Host() string { + return b.server.(*udp.UdpServer).GetHost() +} + func buildMappings(config []StatsdMapping) (map[string]StatsdMapping, error) { mappings := make(map[string]StatsdMapping, len(config)) replacer := strings.NewReplacer(".", `\.`, "<", "(?P<", ">", ">[^.]+)")