diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 5d32024d42a..f384f9509dc 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -145,6 +145,7 @@ Experimental features might be changed or removed without prior notice. | `awsDatasourcesTempCredentials` | Support temporary security credentials in AWS plugins for Grafana Cloud customers | | `mlExpressions` | Enable support for Machine Learning in server-side expressions | | `metricsSummary` | Enables metrics summary queries in the Tempo data source | +| `datasourceAPIServers` | Expose some datasources as apiservers. | | `permissionsFilterRemoveSubquery` | Alternative permission filter implementation that does not use subqueries for fetching the dashboard folder | | `aiGeneratedDashboardChanges` | Enable AI powered features for dashboards to auto-summary changes when saving | | `sseGroupByDatasource` | Send query to the same datasource in a single request when using server side expressions. The `cloudWatchBatchQueries` feature toggle should be enabled if this used with CloudWatch. | @@ -206,8 +207,8 @@ Experimental features might be changed or removed without prior notice. The following toggles require explicitly setting Grafana's [app mode]({{< relref "../_index.md#app_mode" >}}) to 'development' before you can enable this feature toggle. These features tend to be experimental. -| Feature toggle name | Description | -| -------------------------------------- | -------------------------------------------------------------- | -| `grafanaAPIServerWithExperimentalAPIs` | Register experimental APIs with the k8s API server | -| `grafanaAPIServerEnsureKubectlAccess` | Start an additional https handler and write kubectl options | -| `panelTitleSearchInV1` | Enable searching for dashboards using panel title in search v1 | +| Feature toggle name | Description | +| -------------------------------------- | ----------------------------------------------------------------------------- | +| `grafanaAPIServerWithExperimentalAPIs` | Register experimental APIs with the k8s API server, including all datasources | +| `grafanaAPIServerEnsureKubectlAccess` | Start an additional https handler and write kubectl options | +| `panelTitleSearchInV1` | Enable searching for dashboards using panel title in search v1 | diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 157be39c9cd..376ab32e981 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -87,6 +87,7 @@ export interface FeatureToggles { mlExpressions?: boolean; traceQLStreaming?: boolean; metricsSummary?: boolean; + datasourceAPIServers?: boolean; grafanaAPIServerWithExperimentalAPIs?: boolean; grafanaAPIServerEnsureKubectlAccess?: boolean; featureToggleAdminPage?: boolean; diff --git a/pkg/registry/apis/datasource/register.go b/pkg/registry/apis/datasource/register.go index 7574e5da72a..120a8e9acb0 100644 --- a/pkg/registry/apis/datasource/register.go +++ b/pkg/registry/apis/datasource/register.go @@ -58,8 +58,11 @@ func RegisterAPIService( accessControl accesscontrol.AccessControl, reg prometheus.Registerer, ) (*DataSourceAPIBuilder, error) { + // We want to expose just a limited set of plugins + explictPluginList := features.IsEnabledGlobally(featuremgmt.FlagDatasourceAPIServers) + // This requires devmode! - if !features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs) { + if !(explictPluginList || features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs)) { return nil, nil // skip registration unless opting into experimental apis } @@ -73,7 +76,7 @@ func RegisterAPIService( } for _, ds := range all { - if !slices.Contains(ids, ds.ID) { + if explictPluginList && !slices.Contains(ids, ds.ID) { continue // skip this one } diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index c4d47a86cb5..a69c4e69a34 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -517,9 +517,16 @@ var ( FrontendOnly: true, Owner: grafanaObservabilityTracesAndProfilingSquad, }, + { + Name: "datasourceAPIServers", + Description: "Expose some datasources as apiservers.", + Stage: FeatureStageExperimental, + Owner: grafanaAppPlatformSquad, + RequiresRestart: true, // changes the API routing + }, { Name: "grafanaAPIServerWithExperimentalAPIs", - Description: "Register experimental APIs with the k8s API server", + Description: "Register experimental APIs with the k8s API server, including all datasources", Stage: FeatureStageExperimental, RequiresRestart: true, RequiresDevMode: true, diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index f490900f3f5..6a7bfda8ce1 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -68,6 +68,7 @@ transformationsRedesign,GA,@grafana/observability-metrics,false,false,true mlExpressions,experimental,@grafana/alerting-squad,false,false,false traceQLStreaming,GA,@grafana/observability-traces-and-profiling,false,false,true metricsSummary,experimental,@grafana/observability-traces-and-profiling,false,false,true +datasourceAPIServers,experimental,@grafana/grafana-app-platform-squad,false,true,false grafanaAPIServerWithExperimentalAPIs,experimental,@grafana/grafana-app-platform-squad,true,true,false grafanaAPIServerEnsureKubectlAccess,experimental,@grafana/grafana-app-platform-squad,true,true,false featureToggleAdminPage,experimental,@grafana/grafana-operator-experience-squad,false,true,false diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 35f51eaefaf..beae9a2e50d 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -283,8 +283,12 @@ const ( // Enables metrics summary queries in the Tempo data source FlagMetricsSummary = "metricsSummary" + // FlagDatasourceAPIServers + // Expose some datasources as apiservers. + FlagDatasourceAPIServers = "datasourceAPIServers" + // FlagGrafanaAPIServerWithExperimentalAPIs - // Register experimental APIs with the k8s API server + // Register experimental APIs with the k8s API server, including all datasources FlagGrafanaAPIServerWithExperimentalAPIs = "grafanaAPIServerWithExperimentalAPIs" // FlagGrafanaAPIServerEnsureKubectlAccess diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index 3547db321d4..f2730d6f456 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -909,6 +909,22 @@ "expression": "true" } }, + { + "metadata": { + "name": "datasourceAPIServers", + "resourceVersion": "1726731672938", + "creationTimestamp": "2024-09-12T07:32:40Z", + "annotations": { + "grafana.app/updatedTimestamp": "2024-09-19 07:41:12.938146 +0000 UTC" + } + }, + "spec": { + "description": "Expose some datasources as apiservers.", + "stage": "experimental", + "codeowner": "@grafana/grafana-app-platform-squad", + "requiresRestart": true + } + }, { "metadata": { "name": "datasourceProxyDisableRBAC", @@ -1327,11 +1343,14 @@ { "metadata": { "name": "grafanaAPIServerWithExperimentalAPIs", - "resourceVersion": "1718727528075", - "creationTimestamp": "2023-10-06T18:55:22Z" + "resourceVersion": "1726731672938", + "creationTimestamp": "2023-10-06T18:55:22Z", + "annotations": { + "grafana.app/updatedTimestamp": "2024-09-19 07:41:12.938146 +0000 UTC" + } }, "spec": { - "description": "Register experimental APIs with the k8s API server", + "description": "Register experimental APIs with the k8s API server, including all datasources", "stage": "experimental", "codeowner": "@grafana/grafana-app-platform-squad", "requiresDevMode": true,