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

Fixes #1277 Use the DefaultURL parameter if no url is explicitly set by the user #1278

Closed
wants to merge 4 commits into from
Closed
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.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ time before a new metric is included by the plugin.
- [#1264](https://github.com/influxdata/telegraf/pull/1264): Add SSL config options to http_response plugin.
- [#1272](https://github.com/influxdata/telegraf/pull/1272): graphite parser: add ability to specify multiple tag keys, for consistency with influxdb parser.
- [#1265](https://github.com/influxdata/telegraf/pull/1265): Make dns lookups for chrony configurable. Thanks @zbindenren!
- [#1278](https://github.com/influxdata/telegraf/pull/1278): RabbitMQ input: made url parameter optional by using DefaultURL (http://localhost:15672) if not specified

### Bugfixes

Expand Down
2 changes: 1 addition & 1 deletion etc/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@

# # Read metrics from one or many RabbitMQ servers via the management API
# [[inputs.rabbitmq]]
# url = "http://localhost:15672" # required
# # url = "http://localhost:15672"
# # name = "rmq-server-1" # optional tag
# # username = "guest"
# # password = "guest"
Expand Down
5 changes: 4 additions & 1 deletion plugins/inputs/rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type gatherFunc func(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error)
var gatherFunctions = []gatherFunc{gatherOverview, gatherNodes, gatherQueues}

var sampleConfig = `
url = "http://localhost:15672" # required
# url = "http://localhost:15672"
# name = "rmq-server-1" # optional tag
# username = "guest"
# password = "guest"
Expand Down Expand Up @@ -146,6 +146,9 @@ func (r *RabbitMQ) Gather(acc telegraf.Accumulator) error {
}

func (r *RabbitMQ) requestJSON(u string, target interface{}) error {
if r.URL == "" {
r.URL = DefaultURL
}
u = fmt.Sprintf("%s%s", r.URL, u)

req, err := http.NewRequest("GET", u, nil)
Expand Down