AlertingNG/SSE: Datasource UID and UID/ID only (drop name) (#33039)

SSE still will support ID until dashboard/frontend always requests UID
update *.http examples

Co-authored-by: gotjosh <josue@grafana.com>
This commit is contained in:
Kyle Brandt
2021-04-16 15:29:19 +02:00
committed by GitHub
co-authored by gotjosh
parent 5d1ec39224
commit 2c862678ab
11 changed files with 40 additions and 71 deletions
+7 -2
View File
@@ -134,9 +134,14 @@ func (s *Service) buildGraph(req *backend.QueryDataRequest) (*simple.DirectedGra
return nil, err
}
dsUID, err := rn.GetDatasourceUid()
if err != nil {
return nil, err
}
var node graph.Node
switch dsName {
case DatasourceName:
switch {
case dsName == DatasourceName || dsUID == DatasourceUID:
node, err = buildCMDNode(dp, rn)
default: // If it's not an expression query, it's a data source query.
node, err = s.buildDSNode(dp, rn, req.PluginContext.OrgID)
+13 -1
View File
@@ -30,7 +30,7 @@ type rawNode struct {
func (rn *rawNode) GetDatasourceName() (string, error) {
rawDs, ok := rn.Query["datasource"]
if !ok {
return "", fmt.Errorf("no datasource in query for refId %v", rn.RefID)
return "", nil
}
dsName, ok := rawDs.(string)
if !ok {
@@ -39,6 +39,18 @@ func (rn *rawNode) GetDatasourceName() (string, error) {
return dsName, nil
}
func (rn *rawNode) GetDatasourceUid() (string, error) {
rawDs, ok := rn.Query["datasourceUid"]
if !ok {
return "", nil
}
dsUID, ok := rawDs.(string)
if !ok {
return "", fmt.Errorf("expected datasource identifier to be a string, got %T", rawDs)
}
return dsUID, nil
}
func (rn *rawNode) GetCommandType() (c CommandType, err error) {
rawType, ok := rn.Query["type"]
if !ok {
+5 -5
View File
@@ -240,14 +240,14 @@ func (dc *dashConditionsJSON) GetNew(orgID int64) (*ngmodels.Condition, error) {
ngCond.OrgID = orgID
exprModel := struct {
Type string `json:"type"`
RefID string `json:"refId"`
Datasource string `json:"datasource"`
Conditions []classic.ClassicConditionJSON `json:"conditions"`
Type string `json:"type"`
RefID string `json:"refId"`
DatasourceUID string `json:"datasourceUid"`
Conditions []classic.ClassicConditionJSON `json:"conditions"`
}{
"classic_conditions",
ccRefID,
"__expr__",
expr.DatasourceUID,
conditions,
}