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:
@@ -647,5 +647,12 @@ var (
|
||||
FrontendOnly: true,
|
||||
Owner: grafanaObservabilityMetricsSquad,
|
||||
},
|
||||
{
|
||||
Name: "mlExpressions",
|
||||
Description: "Enable support for Machine Learning in server-side expressions",
|
||||
Stage: FeatureStageExperimental,
|
||||
FrontendOnly: false,
|
||||
Owner: grafanaAlertingSquad,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -94,3 +94,4 @@ prometheusIncrementalQueryInstrumentation,experimental,@grafana/observability-me
|
||||
logsExploreTableVisualisation,experimental,@grafana/observability-logs,false,false,false,true
|
||||
awsDatasourcesTempCredentials,experimental,@grafana/aws-datasources,false,false,false,false
|
||||
transformationsRedesign,experimental,@grafana/observability-metrics,false,false,false,true
|
||||
mlExpressions,experimental,@grafana/alerting-squad,false,false,false,false
|
||||
|
||||
|
@@ -386,4 +386,8 @@ const (
|
||||
// FlagTransformationsRedesign
|
||||
// Enables the transformations redesign
|
||||
FlagTransformationsRedesign = "transformationsRedesign"
|
||||
|
||||
// FlagMlExpressions
|
||||
// Enable support for Machine Learning in server-side expressions
|
||||
FlagMlExpressions = "mlExpressions"
|
||||
)
|
||||
|
||||
@@ -270,10 +270,10 @@ func getExprRequest(ctx EvaluationContext, data []models.AlertQuery, dsCacheServ
|
||||
ds, ok := datasources[q.DatasourceUID]
|
||||
if !ok {
|
||||
switch nodeType := expr.NodeTypeFromDatasourceUID(q.DatasourceUID); nodeType {
|
||||
case expr.TypeCMDNode:
|
||||
ds, err = expr.DataSourceModelFromNodeType(nodeType)
|
||||
case expr.TypeDatasourceNode:
|
||||
ds, err = dsCacheService.GetDatasourceByUID(ctx.Ctx, q.DatasourceUID, ctx.User, false /*skipCache*/)
|
||||
default:
|
||||
ds, err = expr.DataSourceModelFromNodeType(nodeType)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to build query '%s': %w", q.RefID, err)
|
||||
@@ -622,15 +622,24 @@ func (e *evaluatorImpl) Validate(ctx EvaluationContext, condition models.Conditi
|
||||
return err
|
||||
}
|
||||
for _, query := range req.Queries {
|
||||
if query.DataSource == nil || expr.NodeTypeFromDatasourceUID(query.DataSource.UID) != expr.TypeDatasourceNode {
|
||||
if query.DataSource == nil {
|
||||
continue
|
||||
}
|
||||
p, found := e.pluginsStore.Plugin(ctx.Ctx, query.DataSource.Type)
|
||||
if !found { // technically this should fail earlier during datasource resolution phase.
|
||||
return fmt.Errorf("datasource refID %s could not be found: %w", query.RefID, plugins.ErrPluginUnavailable)
|
||||
}
|
||||
if !p.Backend {
|
||||
return fmt.Errorf("datasource refID %s is not a backend datasource", query.RefID)
|
||||
switch expr.NodeTypeFromDatasourceUID(query.DataSource.UID) {
|
||||
case expr.TypeDatasourceNode:
|
||||
p, found := e.pluginsStore.Plugin(ctx.Ctx, query.DataSource.Type)
|
||||
if !found { // technically this should fail earlier during datasource resolution phase.
|
||||
return fmt.Errorf("datasource refID %s could not be found: %w", query.RefID, plugins.ErrPluginUnavailable)
|
||||
}
|
||||
if !p.Backend {
|
||||
return fmt.Errorf("datasource refID %s is not a backend datasource", query.RefID)
|
||||
}
|
||||
case expr.TypeMLNode:
|
||||
_, found := e.pluginsStore.Plugin(ctx.Ctx, query.DataSource.Type)
|
||||
if !found {
|
||||
return fmt.Errorf("datasource refID %s could not be found: %w", query.RefID, plugins.ErrPluginUnavailable)
|
||||
}
|
||||
case expr.TypeCMDNode:
|
||||
}
|
||||
}
|
||||
_, err = e.create(condition, req)
|
||||
|
||||
Reference in New Issue
Block a user