Skip to content

Commit

Permalink
Fix: don't miss address scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Tojek committed Feb 9, 2020
1 parent 790036b commit bd79321
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Change lookup_fields from metricset.host to service.address {pull}15883[15883]
- Add dedot for cloudwatch metric name. {issue}15916[15916] {pull}15917[15917]
- Fixed issue `logstash-xpack` module suddenly ceasing to monitor Logstash. {issue}15974[15974] {pull}16044[16044]
- Fix skipping protocol scheme by light modules. {pull}16205[pull]

*Packetbeat*

Expand Down
16 changes: 15 additions & 1 deletion metricbeat/mb/lightmetricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
package mb

import (
"fmt"
"net/url"

"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"
Expand Down Expand Up @@ -83,7 +86,18 @@ func (m *LightMetricSet) Registration(r *Register) (MetricSetRegistration, error
// At this point host parser was already run, we need to run this again
// with the overriden defaults
if registration.HostParser != nil {
base.hostData, err = registration.HostParser(base.module, base.host)
u, err := url.Parse(base.hostData.URI)
if err != nil {
return nil, errors.Wrapf(err, "host data URI parsing failed on light metricset factory for '%s/%s'", m.Module, m.Name)
}

var host string
if u.Scheme != "" {
host = fmt.Sprintf("%s://%s", u.Scheme, u.Host)
} else {
host = base.host
}
base.hostData, err = registration.HostParser(base.module, host)
if err != nil {
return nil, errors.Wrapf(err, "host parser failed on light metricset factory for '%s/%s'", m.Module, m.Name)
}
Expand Down

0 comments on commit bd79321

Please sign in to comment.