diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ab1e5c1..3833d71c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ re-added in a "verbose" mode if there is demand for it. - [#203](https://github.com/influxdb/telegraf/pull/200): AMQP output. Thanks @ekini! - [#182](https://github.com/influxdb/telegraf/pull/182): OpenTSDB output. Thanks @rplessl! - [#187](https://github.com/influxdb/telegraf/pull/187): Retry output sink connections on startup. +- [#220](https://github.com/influxdb/telegraf/pull/220): Add port tag to apache plugin. Thanks @neezgee! ### Bugfixes - [#170](https://github.com/influxdb/telegraf/issues/170): Systemd support diff --git a/plugins/apache/apache.go b/plugins/apache/apache.go index bd6c6ad49..f4098b331 100644 --- a/plugins/apache/apache.go +++ b/plugins/apache/apache.go @@ -134,11 +134,18 @@ func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[str // Get tag(s) for the apache plugin func getTags(addr *url.URL) map[string]string { h := addr.Host - if host, port, err := net.SplitHostPort(h); err == nil { - return map[string]string{"server": host, "port": port} - } else { - return map[string]string{"server": h, "port": "80"} + host, port, err := net.SplitHostPort(h) + if err != nil { + host = addr.Host + if addr.Scheme == "http" { + port = "80" + } else if addr.Scheme == "https" { + port = "443" + } else { + port = "" + } } + return map[string]string{"server": host, "port": port} } func init() {