Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override host on statsd metricset #29103

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*

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