SSE: Dataplane Compliance (#65927)

Takes a specific code path for data that identifies itself as dataplane instead of "guessing" what the data is.

The data must identify itself by being in the dataplane by having both the following frame metadata properties:

- TypeVersion property that is greater than 0.0
- 'Type' property

The flag is disableSSEDataplane and disables this functionality and uses the old code for all queries regardless.

See https://github.com/grafana/grafana-plugin-sdk-go/blob/main/data/contract_docs/contract.md for dataplane details.
This commit is contained in:
Kyle Brandt
2023-04-12 12:24:34 -04:00
committed by GitHub
parent b83627a661
commit e78be44e1a
17 changed files with 480 additions and 6 deletions
+6
View File
@@ -475,6 +475,12 @@ var (
State: FeatureStateAlpha,
Owner: grafanaAlertingSquad,
},
{
Name: "disableSSEDataplane",
Description: "Disables dataplane specific processing in server side expressions.",
State: FeatureStateAlpha,
Owner: grafanaObservabilityMetricsSquad,
},
{
Name: "unifiedRequestLog",
Description: "Writes error logs to the request logger",
+1
View File
@@ -70,6 +70,7 @@ prometheusDataplane,alpha,@grafana/observability-metrics,false,false,false,false
alertStateHistoryLokiSecondary,alpha,@grafana/alerting-squad,false,false,false,false
alertStateHistoryLokiPrimary,alpha,@grafana/alerting-squad,false,false,false,false
alertStateHistoryLokiOnly,alpha,@grafana/alerting-squad,false,false,false,false
disableSSEDataplane,alpha,@grafana/observability-metrics,false,false,false,false
unifiedRequestLog,alpha,@grafana/backend-platform,false,false,false,false
renderAuthJWT,beta,@grafana/grafana-as-code,false,false,false,false
pyroscopeFlameGraph,alpha,@grafana/observability-traces-and-profiling,false,false,false,false
1 Name State Owner requiresDevMode RequiresLicense RequiresRestart FrontendOnly
70 alertStateHistoryLokiSecondary alpha @grafana/alerting-squad false false false false
71 alertStateHistoryLokiPrimary alpha @grafana/alerting-squad false false false false
72 alertStateHistoryLokiOnly alpha @grafana/alerting-squad false false false false
73 disableSSEDataplane alpha @grafana/observability-metrics false false false false
74 unifiedRequestLog alpha @grafana/backend-platform false false false false
75 renderAuthJWT beta @grafana/grafana-as-code false false false false
76 pyroscopeFlameGraph alpha @grafana/observability-traces-and-profiling false false false false
+4
View File
@@ -291,6 +291,10 @@ const (
// Disable Grafana alerts from emitting annotations when a remote Loki instance is available.
FlagAlertStateHistoryLokiOnly = "alertStateHistoryLokiOnly"
// FlagDisableSSEDataplane
// Disables dataplane specific processing in server side expressions.
FlagDisableSSEDataplane = "disableSSEDataplane"
// FlagUnifiedRequestLog
// Writes error logs to the request logger
FlagUnifiedRequestLog = "unifiedRequestLog"
+2 -1
View File
@@ -15,6 +15,7 @@ import (
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/datasources"
fakes "github.com/grafana/grafana/pkg/services/datasources/fakes"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
@@ -532,7 +533,7 @@ func TestValidate(t *testing.T) {
pluginsStore: store,
})
evaluator := NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, cacheService, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil), store)
evaluator := NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, cacheService, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, &featuremgmt.FeatureManager{}), store)
evalCtx := NewContext(context.Background(), u)
err := evaluator.Validate(evalCtx, condition)
@@ -24,6 +24,7 @@ import (
"github.com/grafana/grafana/pkg/expr"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/eval"
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
@@ -780,7 +781,7 @@ func setupScheduler(t *testing.T, rs *fakeRulesStore, is *state.FakeInstanceStor
var evaluator = evalMock
if evalMock == nil {
evaluator = eval.NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, nil, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil), &plugins.FakePluginStore{})
evaluator = eval.NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, nil, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, &featuremgmt.FeatureManager{}), &plugins.FakePluginStore{})
}
if registry == nil {
+1 -1
View File
@@ -446,7 +446,7 @@ func setup(t *testing.T) *testContext {
DataSources: nil,
SimulatePluginFailure: false,
}
exprService := expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, pc, fakeDatasourceService)
exprService := expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, pc, fakeDatasourceService, &featuremgmt.FeatureManager{})
queryService := ProvideService(setting.NewCfg(), dc, exprService, rv, ds, pc) // provider belonging to this package
return &testContext{
pluginContext: pc,