Skip to content

Commit

Permalink
Metricbeat: Set guest as default user in RabbitMQ module
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed May 23, 2018
1 parent 0a85fce commit ffe620f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ https://github.com/elastic/beats/compare/v6.2.3...master[Check the HEAD diff]
- Add shard metricset to Elasticsearch module. {pull}7006[7006]
- Add apiserver metricset to Kubernetes module. {pull}7059[7059]
- Add maxmemory to redis info metricset. {pull}7127[7127]
- Set guest as default user in RabbitMQ module. {pull}7107[7107]

*Packetbeat*

Expand Down
14 changes: 10 additions & 4 deletions metricbeat/mb/parse/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import (
// URLHostParserBuilder builds a tailored HostParser for used with host strings
// that are URLs.
type URLHostParserBuilder struct {
PathConfigKey string
DefaultPath string
DefaultScheme string
QueryParams string
PathConfigKey string
DefaultPath string
DefaultUsername string
DefaultPassword string
DefaultScheme string
QueryParams string
}

// Build returns a new HostParser function whose behavior is influenced by the
Expand All @@ -37,13 +39,17 @@ func (b URLHostParserBuilder) Build() mb.HostParser {
if !ok {
return mb.HostData{}, errors.Errorf("'username' config for module %v is not a string", module.Name())
}
} else {
user = b.DefaultUsername
}
t, ok = conf["password"]
if ok {
pass, ok = t.(string)
if !ok {
return mb.HostData{}, errors.Errorf("'password' config for module %v is not a string", module.Name())
}
} else {
pass = b.DefaultPassword
}
t, ok = conf[b.PathConfigKey]
if ok {
Expand Down
6 changes: 4 additions & 2 deletions metricbeat/module/rabbitmq/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const (
var (
// HostParser parses host urls for RabbitMQ management plugin
HostParser = parse.URLHostParserBuilder{
DefaultScheme: defaultScheme,
PathConfigKey: pathConfigKey,
DefaultScheme: defaultScheme,
PathConfigKey: pathConfigKey,
DefaultUsername: "guest",
DefaultPassword: "guest",
}.Build()
)

0 comments on commit ffe620f

Please sign in to comment.