From d73547c0dc165e157adea006db7a539fe8e5e903 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 1 Sep 2016 11:12:35 +0200 Subject: [PATCH] feat(tsdb): add missing content type and join url using path --- pkg/tsdb/graphite/graphite.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/tsdb/graphite/graphite.go b/pkg/tsdb/graphite/graphite.go index a6295292d7e..793aeefe568 100644 --- a/pkg/tsdb/graphite/graphite.go +++ b/pkg/tsdb/graphite/graphite.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "net/http" "net/url" + "path" "strings" "time" @@ -44,18 +45,20 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC for _, query := range queries { params["target"] = []string{query.Query} - glog.Debug("Graphite request", "query", query.Query) } - formData := params.Encode() - glog.Info("Graphite request body", "formdata", formData) - req, err := http.NewRequest(http.MethodPost, e.Url+"/render", strings.NewReader(formData)) + u, _ := url.Parse(e.Url) + u.Path = path.Join(u.Path, "render") + glog.Info("Graphite request body", "formdata", params.Encode()) + + req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(params.Encode())) if err != nil { glog.Info("Failed to create request", "error", err) result.Error = fmt.Errorf("Failed to create request. error: %v", err) return result } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") if e.BasicAuth { req.SetBasicAuth(e.BasicAuthUser, e.BasicAuthPassword) }