From 7277b487a4e0bb6c24ce42275b9f81e8ad47fa95 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Tue, 23 Nov 2021 16:24:44 +0100 Subject: [PATCH 1/2] override host on statsd metricset --- metricbeat/helper/server/udp/udp.go | 4 ++++ x-pack/metricbeat/module/statsd/server/server.go | 6 ++++++ 2 files changed, 10 insertions(+) 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<", ">", ">[^.]+)") From f7e664dceb53f057ea137015f4670a2ce895b0d1 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Tue, 23 Nov 2021 18:49:04 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 8308f6c3a41..07d47fb9508 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -371,6 +371,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*