提交 1d847e2c 编写于 作者: U Ulric Qin

refactor datasource check of loki

上级 5b811b70
......@@ -137,14 +137,15 @@ func DatasourceCheck(ds models.Datasource) error {
if ds.PluginType == models.PROMETHEUS {
subPath := "/api/v1/query"
query := url.Values{}
if strings.Contains(fullURL, "loki") {
subPath = "/api/v1/labels"
} else {
query.Add("query", "1+1")
}
// if strings.Contains(fullURL, "loki") {
// subPath = "/api/v1/labels"
// } else {
// query.Add("query", "1+1")
// }
query.Add("query", "mock_metric_name")
fullURL = fmt.Sprintf("%s%s?%s", ds.HTTPJson.Url, subPath, query.Encode())
req, err = http.NewRequest("POST", fullURL, nil)
req, err = http.NewRequest("GET", fullURL, nil)
if err != nil {
logger.Errorf("Error creating request: %v", err)
return fmt.Errorf("request url:%s failed", fullURL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册