Skip to content

Commit

Permalink
override host on statsd metricset (#29103)
Browse files Browse the repository at this point in the history
* override host on statsd metricset

* changelog

(cherry picked from commit 606a7d2)
  • Loading branch information
Andrea Spacca authored and mergify-bot committed Nov 24, 2021
1 parent f170c46 commit d31e215
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Added a new beta `enterprisesearch` module for Elastic Enterprise Search {pull}27549[27549]
- 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*

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/helper/server/udp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions x-pack/metricbeat/module/statsd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<", ">", ">[^.]+)")
Expand Down

0 comments on commit d31e215

Please sign in to comment.