Commit c0697b99 by bergquist

fix(alerting): adds support for basic auth

closes #5897
parent 9c08d7ae
......@@ -110,6 +110,12 @@ func (c *QueryCondition) getRequestForAlertRule(datasource *m.DataSource) *tsdb.
Name: datasource.Name,
PluginId: datasource.Type,
Url: datasource.Url,
User: datasource.User,
Password: datasource.Password,
Database: datasource.Database,
BasicAuth: datasource.BasicAuth,
BasicAuthUser: datasource.BasicAuthUser,
BasicAuthPassword: datasource.BasicAuthPassword,
},
},
},
......
......@@ -43,12 +43,17 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
}
client := http.Client{Timeout: time.Duration(10 * time.Second)}
res, err := client.PostForm(e.Url+"/render?", params)
req, _ := http.NewRequest(http.MethodPost, e.Url+"/render?", strings.NewReader(params.Encode()))
if e.BasicAuth {
req.SetBasicAuth("carl", "carl")
}
res, err := client.Do(req)
defer res.Body.Close()
if err != nil {
result.Error = err
return result
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment