From c4bbc18cb6d28f2b324328eb822712dff7f3bf23 Mon Sep 17 00:00:00 2001 From: Ruslan Islamgaliev Date: Wed, 23 Sep 2015 21:43:44 +0300 Subject: [PATCH] Make nginx_test check port in nginx module tags Closes #223 --- CHANGELOG.md | 1 + plugins/nginx/nginx_test.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2cbc96e6..7949ea01c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#205](https://github.com/influxdb/telegraf/issues/205): Include per-db redis keyspace info - [#226](https://github.com/influxdb/telegraf/pull/226): Add timestamps to points in Kafka/AMQP outputs. Thanks @ekini - [#90](https://github.com/influxdb/telegraf/issues/90): Add Docker labels to tags in docker plugin +- [#223](https://github.com/influxdb/telegraf/pull/223): Add port tag to nginx plugin. Thanks @neezgee! ### Bugfixes diff --git a/plugins/nginx/nginx_test.go b/plugins/nginx/nginx_test.go index 5e1eb1e79..4031baf59 100644 --- a/plugins/nginx/nginx_test.go +++ b/plugins/nginx/nginx_test.go @@ -70,8 +70,20 @@ func TestNginxGeneratesMetrics(t *testing.T) { if err != nil { panic(err) } - host, _, _ := net.SplitHostPort(addr.Host) - tags := map[string]string{"server": host} + + host, port, err := net.SplitHostPort(addr.Host) + if err != nil { + host = addr.Host + if addr.Scheme == "http" { + port = "80" + } else if addr.Scheme == "https" { + port = "443" + } else { + port = "" + } + } + + tags := map[string]string{"server": host, "port": port} for _, m := range metrics { assert.NoError(t, acc.ValidateTaggedValue(m.name, m.value, tags))