diff --git a/plugins/inputs/haproxy/haproxy.go b/plugins/inputs/haproxy/haproxy.go index fb028c26d..942453ab4 100644 --- a/plugins/inputs/haproxy/haproxy.go +++ b/plugins/inputs/haproxy/haproxy.go @@ -107,7 +107,7 @@ func (r *haproxy) Description() string { // Returns one of the errors encountered while gather stats (if any). func (g *haproxy) Gather(acc telegraf.Accumulator) error { if len(g.Servers) == 0 { - return g.gatherServer("http://127.0.0.1:1936", acc) + return g.gatherServer("http://127.0.0.1:1936/;csv", acc) } var wg sync.WaitGroup @@ -140,15 +140,9 @@ func (g *haproxy) gatherServer(addr string, acc telegraf.Accumulator) error { u, err := url.Parse(addr) if err != nil { return fmt.Errorf("Unable parse server address '%s': %s", addr, err) - } - var uri string + } //Checking for default Haproxy Status page - if u.RawQuery == "" { - uri = fmt.Sprintf("%s://%s%s;csv", u.Scheme, u.Host, u.Path) - } else { - uri = fmt.Sprintf("%s://%s%s?%s;csv", u.Scheme, u.Host, u.Path, u.RawQuery) - } - req, err := http.NewRequest("GET", uri, nil) + req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s%s?%s", u.Scheme, u.Host, u.Path, u.RawQuery), nil) if u.User != nil { p, _ := u.User.Password() req.SetBasicAuth(u.User.Username(), p)