Commit c0697b99 by bergquist

fix(alerting): adds support for basic auth

closes #5897
parent 9c08d7ae
...@@ -106,10 +106,16 @@ func (c *QueryCondition) getRequestForAlertRule(datasource *m.DataSource) *tsdb. ...@@ -106,10 +106,16 @@ func (c *QueryCondition) getRequestForAlertRule(datasource *m.DataSource) *tsdb.
RefId: "A", RefId: "A",
Query: c.Query.Model.Get("target").MustString(), Query: c.Query.Model.Get("target").MustString(),
DataSource: &tsdb.DataSourceInfo{ DataSource: &tsdb.DataSourceInfo{
Id: datasource.Id, Id: datasource.Id,
Name: datasource.Name, Name: datasource.Name,
PluginId: datasource.Type, PluginId: datasource.Type,
Url: datasource.Url, 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 ...@@ -43,12 +43,17 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
} }
client := http.Client{Timeout: time.Duration(10 * time.Second)} 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 { if err != nil {
result.Error = err result.Error = err
return result return result
} }
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body) body, err := ioutil.ReadAll(res.Body)
if err != nil { 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