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:
+7
-2
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user