mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
Graphite: Don't issue empty "select metric" queries (#22699)
* Don't issue empty "select metric" queries * Update pkg/tsdb/graphite/graphite.go Co-Authored-By: Carl Bergquist <carl.bergquist@gmail.com> * Fix indentation * Add missing import Co-authored-by: Carl Bergquist <carl.bergquist@gmail.com>
This commit is contained in:
parent
cf6adb8b54
commit
c6829645c7
@ -3,6 +3,7 @@ package graphite
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@ -48,13 +49,26 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
|
||||
"maxDataPoints": []string{"500"},
|
||||
}
|
||||
|
||||
emptyQueries := make([]string, 0)
|
||||
for _, query := range tsdbQuery.Queries {
|
||||
glog.Debug("graphite", "query", query.Model)
|
||||
currTarget := ""
|
||||
if fullTarget, err := query.Model.Get("targetFull").String(); err == nil {
|
||||
target = fixIntervalFormat(fullTarget)
|
||||
currTarget = fullTarget
|
||||
} else {
|
||||
target = fixIntervalFormat(query.Model.Get("target").MustString())
|
||||
currTarget = query.Model.Get("target").MustString()
|
||||
}
|
||||
if currTarget == "" {
|
||||
glog.Debug("graphite", "empty query target", query.Model)
|
||||
emptyQueries = append(emptyQueries, fmt.Sprintf("Query: %v has no target", query.Model))
|
||||
continue
|
||||
}
|
||||
target = fixIntervalFormat(currTarget)
|
||||
}
|
||||
|
||||
if target == "" {
|
||||
glog.Error("No targets in query model", "models without targets", strings.Join(emptyQueries, "\n"))
|
||||
return nil, errors.New("No query target found for the alert rule")
|
||||
}
|
||||
|
||||
formData["target"] = []string{target}
|
||||
|
Loading…
Reference in New Issue
Block a user