From 42d7fc5e16499c1958d3e73e7265ca550b19413c Mon Sep 17 00:00:00 2001 From: Martin Seener Date: Thu, 26 May 2016 11:25:21 +0200 Subject: [PATCH] Use the DefaultURL parameter if no url is explicitly set by the user closes #1278 closes #1277 --- CHANGELOG.md | 1 + etc/telegraf.conf | 2 +- plugins/inputs/rabbitmq/rabbitmq.go | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6beaa632..6ad41f55b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ time before a new metric is included by the plugin. - [#1265](https://github.com/influxdata/telegraf/pull/1265): Make dns lookups for chrony configurable. Thanks @zbindenren! - [#1275](https://github.com/influxdata/telegraf/pull/1275): Allow wildcard filtering of varnish stats. - [#1142](https://github.com/influxdata/telegraf/pull/1142): Support for glob patterns in exec plugin commands configuration. +- [#1278](https://github.com/influxdata/telegraf/pull/1278): RabbitMQ input: made url parameter optional by using DefaultURL (http://localhost:15672) if not specified ### Bugfixes diff --git a/etc/telegraf.conf b/etc/telegraf.conf index c5d631f51..05f47e861 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -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" diff --git a/plugins/inputs/rabbitmq/rabbitmq.go b/plugins/inputs/rabbitmq/rabbitmq.go index 4d119282d..bf6859002 100644 --- a/plugins/inputs/rabbitmq/rabbitmq.go +++ b/plugins/inputs/rabbitmq/rabbitmq.go @@ -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" @@ -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)