SSE: Support for ML query node (#69963)
* introduce a new node-type ML and implement a command outlier that uses ML plugin as a source of data. * add feature flag mlExpressions that guards the feature
This commit is contained in:
+16
-1
@@ -11,6 +11,7 @@ import (
|
||||
"gonum.org/v1/gonum/graph/topo"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr/mathexp"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
|
||||
// NodeType is the type of a DPNode. Currently either a expression command or datasource query.
|
||||
@@ -21,6 +22,8 @@ const (
|
||||
TypeCMDNode NodeType = iota
|
||||
// TypeDatasourceNode is a NodeType for datasource queries.
|
||||
TypeDatasourceNode
|
||||
// TypeMLNode is a NodeType for Machine Learning queries.
|
||||
TypeMLNode
|
||||
)
|
||||
|
||||
func (nt NodeType) String() string {
|
||||
@@ -29,6 +32,8 @@ func (nt NodeType) String() string {
|
||||
return "Expression"
|
||||
case TypeDatasourceNode:
|
||||
return "Datasource"
|
||||
case TypeMLNode:
|
||||
return "Machine Learning"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
@@ -159,6 +164,7 @@ func (s *Service) buildGraph(req *Request) (*simple.DirectedGraph, error) {
|
||||
|
||||
rn := &rawNode{
|
||||
Query: rawQueryProp,
|
||||
QueryRaw: query.JSON,
|
||||
RefID: query.RefID,
|
||||
TimeRange: query.TimeRange,
|
||||
QueryType: query.QueryType,
|
||||
@@ -171,7 +177,16 @@ func (s *Service) buildGraph(req *Request) (*simple.DirectedGraph, error) {
|
||||
node, err = s.buildDSNode(dp, rn, req)
|
||||
case TypeCMDNode:
|
||||
node, err = buildCMDNode(dp, rn)
|
||||
default:
|
||||
case TypeMLNode:
|
||||
if s.features.IsEnabled(featuremgmt.FlagMlExpressions) {
|
||||
node, err = s.buildMLNode(dp, rn, req)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("fail to parse expression with refID %v: %w", rn.RefID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if node == nil && err == nil {
|
||||
err = fmt.Errorf("unsupported node type '%s'", NodeTypeFromDatasourceUID(query.DataSource.UID))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user