Skip to content

Commit 72edc3c

Browse files
neezgeesparrc
authored andcommitted
Select default apache port depending on url scheme
1 parent 5657e8d commit 72edc3c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ re-added in a "verbose" mode if there is demand for it.
1818
- [#203](https://github.com/influxdb/telegraf/pull/200): AMQP output. Thanks @ekini!
1919
- [#182](https://github.com/influxdb/telegraf/pull/182): OpenTSDB output. Thanks @rplessl!
2020
- [#187](https://github.com/influxdb/telegraf/pull/187): Retry output sink connections on startup.
21+
- [#220](https://github.com/influxdb/telegraf/pull/220): Add port tag to apache plugin. Thanks @neezgee!
2122

2223
### Bugfixes
2324
- [#170](https://github.com/influxdb/telegraf/issues/170): Systemd support

plugins/apache/apache.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,18 @@ func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[str
134134
// Get tag(s) for the apache plugin
135135
func getTags(addr *url.URL) map[string]string {
136136
h := addr.Host
137-
if host, port, err := net.SplitHostPort(h); err == nil {
138-
return map[string]string{"server": host, "port": port}
139-
} else {
140-
return map[string]string{"server": h, "port": "80"}
137+
host, port, err := net.SplitHostPort(h)
138+
if err != nil {
139+
host = addr.Host
140+
if addr.Scheme == "http" {
141+
port = "80"
142+
} else if addr.Scheme == "https" {
143+
port = "443"
144+
} else {
145+
port = ""
146+
}
141147
}
148+
return map[string]string{"server": host, "port": port}
142149
}
143150

144151
func init() {

0 commit comments

Comments
 (0)