mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(tsdb): add missing content type and join url using path
This commit is contained in:
parent
3d3365f242
commit
d73547c0dc
@ -6,6 +6,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -44,18 +45,20 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
|
|||||||
|
|
||||||
for _, query := range queries {
|
for _, query := range queries {
|
||||||
params["target"] = []string{query.Query}
|
params["target"] = []string{query.Query}
|
||||||
glog.Debug("Graphite request", "query", query.Query)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formData := params.Encode()
|
u, _ := url.Parse(e.Url)
|
||||||
glog.Info("Graphite request body", "formdata", formData)
|
u.Path = path.Join(u.Path, "render")
|
||||||
req, err := http.NewRequest(http.MethodPost, e.Url+"/render", strings.NewReader(formData))
|
glog.Info("Graphite request body", "formdata", params.Encode())
|
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(params.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Info("Failed to create request", "error", err)
|
glog.Info("Failed to create request", "error", err)
|
||||||
result.Error = fmt.Errorf("Failed to create request. error: %v", err)
|
result.Error = fmt.Errorf("Failed to create request. error: %v", err)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
if e.BasicAuth {
|
if e.BasicAuth {
|
||||||
req.SetBasicAuth(e.BasicAuthUser, e.BasicAuthPassword)
|
req.SetBasicAuth(e.BasicAuthUser, e.BasicAuthPassword)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user