mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Update alert rule migration to use expanded queries (#42493)
* move targetData to target * use constants instead of literals. * Update comments and add tests Co-authored-by: gotjosh <josue.abreu@gmail.com>
This commit is contained in:
@@ -20,6 +20,8 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -27,7 +29,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/legacydata"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -35,6 +36,11 @@ type Service struct {
|
||||
im instancemgmt.InstanceManager
|
||||
}
|
||||
|
||||
const (
|
||||
TargetFullModelField = "targetFull"
|
||||
TargetModelField = "target"
|
||||
)
|
||||
|
||||
func ProvideService(httpClientProvider httpclient.Provider, registrar plugins.CoreBackendRegistrar) (*Service, error) {
|
||||
s := &Service{
|
||||
logger: log.New("tsdb.graphite"),
|
||||
@@ -126,10 +132,10 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
||||
}
|
||||
s.logger.Debug("graphite", "query", model)
|
||||
currTarget := ""
|
||||
if fullTarget, err := model.Get("targetFull").String(); err == nil {
|
||||
if fullTarget, err := model.Get(TargetFullModelField).String(); err == nil {
|
||||
currTarget = fullTarget
|
||||
} else {
|
||||
currTarget = model.Get("target").MustString()
|
||||
currTarget = model.Get(TargetModelField).MustString()
|
||||
}
|
||||
if currTarget == "" {
|
||||
s.logger.Debug("graphite", "empty query target", model)
|
||||
|
||||
Reference in New Issue
Block a user