Alerting/Expr: New SSE Request/QueryType, alerting move data source UID (#33282)
This commit is contained in:
+13
-26
@@ -21,10 +21,11 @@ type baseNode struct {
|
||||
}
|
||||
|
||||
type rawNode struct {
|
||||
RefID string `json:"refId"`
|
||||
Query map[string]interface{}
|
||||
QueryType string
|
||||
TimeRange backend.TimeRange
|
||||
RefID string `json:"refId"`
|
||||
Query map[string]interface{}
|
||||
QueryType string
|
||||
TimeRange TimeRange
|
||||
DatasourceUID string
|
||||
}
|
||||
|
||||
func (rn *rawNode) GetDatasourceName() (string, error) {
|
||||
@@ -39,18 +40,6 @@ 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 {
|
||||
@@ -144,7 +133,7 @@ type DSNode struct {
|
||||
|
||||
orgID int64
|
||||
queryType string
|
||||
timeRange backend.TimeRange
|
||||
timeRange TimeRange
|
||||
intervalMS int64
|
||||
maxDP int64
|
||||
}
|
||||
@@ -182,15 +171,10 @@ func (s *Service) buildDSNode(dp *simple.DirectedGraph, rn *rawNode, orgID int64
|
||||
}
|
||||
dsNode.datasourceID = int64(floatDsID)
|
||||
default:
|
||||
rawDsUID, ok := rn.Query["datasourceUid"]
|
||||
if !ok {
|
||||
if rn.DatasourceUID == "" {
|
||||
return nil, fmt.Errorf("neither datasourceId or datasourceUid in expression data source request for refId %v", rn.RefID)
|
||||
}
|
||||
strDsUID, ok := rawDsUID.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected datasourceUid to be a string, got type %T for refId %v", rawDsUID, rn.RefID)
|
||||
}
|
||||
dsNode.datasourceUID = strDsUID
|
||||
dsNode.datasourceUID = rn.DatasourceUID
|
||||
}
|
||||
|
||||
var floatIntervalMS float64
|
||||
@@ -230,8 +214,11 @@ func (dn *DSNode) Execute(ctx context.Context, vars mathexp.Vars, s *Service) (m
|
||||
MaxDataPoints: dn.maxDP,
|
||||
Interval: time.Duration(int64(time.Millisecond) * dn.intervalMS),
|
||||
JSON: dn.query,
|
||||
TimeRange: dn.timeRange,
|
||||
QueryType: dn.queryType,
|
||||
TimeRange: backend.TimeRange{
|
||||
From: dn.timeRange.From,
|
||||
To: dn.timeRange.To,
|
||||
},
|
||||
QueryType: dn.queryType,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user