Elasticsearch: Add feature toggle to disable running queries trough backend (#66260)

* Elasticsearch: Create feature toggle to disable running queries trough backend

* Fix frontend tests running trough frontend

* Update description of feature toggle
This commit is contained in:
Ivana Huckova 2023-04-12 14:20:43 +02:00 committed by GitHub
parent 29c43fcf7e
commit 303777e682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 64 deletions

View File

@ -19,39 +19,39 @@ This page contains a list of available feature toggles. To learn how to turn on
Some stable features are enabled by default. You can disable a stable feature by setting the feature flag to "false" in the configuration.
| Feature toggle name | Description | Enabled by default |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `disableEnvelopeEncryption` | Disable envelope encryption (emergency only) | |
| `database_metrics` | Add Prometheus metrics for database tables | |
| `featureHighlights` | Highlight Grafana Enterprise features | |
| `cloudWatchDynamicLabels` | Use dynamic labels instead of alias patterns in CloudWatch datasource | Yes |
| `dataConnectionsConsole` | Enables a new top-level page called Connections. This page is an experiment that provides a better experience when you install and configure data sources and other plugins. | Yes |
| `internationalization` | Enables internationalization | Yes |
| `topnav` | Enables new top navigation and page layouts | Yes |
| `cloudWatchCrossAccountQuerying` | Enables cross-account querying in CloudWatch datasources | Yes |
| `newPanelChromeUI` | Show updated look and feel of grafana-ui PanelChrome: panel header, icons, and menu | Yes |
| `accessTokenExpirationCheck` | Enable OAuth access_token expiration check and token refresh using the refresh_token | |
| `emptyDashboardPage` | Enable the redesigned user interface of a dashboard page that includes no panels | Yes |
| `disablePrometheusExemplarSampling` | Disable Prometheus exemplar sampling | |
| `logsSampleInExplore` | Enables access to the logs sample feature in Explore | Yes |
| Feature toggle name | Description | Enabled by default |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `disableEnvelopeEncryption` | Disable envelope encryption (emergency only) | |
| `database_metrics` | Add Prometheus metrics for database tables | |
| `featureHighlights` | Highlight Grafana Enterprise features | |
| `cloudWatchDynamicLabels` | Use dynamic labels instead of alias patterns in CloudWatch datasource | Yes |
| `dataConnectionsConsole` | Enables a new top-level page called Connections. This page is an experiment that provides a better experience when you install and configure data sources and other plugins. | Yes |
| `internationalization` | Enables internationalization | Yes |
| `topnav` | Enables new top navigation and page layouts | Yes |
| `cloudWatchCrossAccountQuerying` | Enables cross-account querying in CloudWatch datasources | Yes |
| `newPanelChromeUI` | Show updated look and feel of grafana-ui PanelChrome: panel header, icons, and menu | Yes |
| `accessTokenExpirationCheck` | Enable OAuth access_token expiration check and token refresh using the refresh_token | |
| `emptyDashboardPage` | Enable the redesigned user interface of a dashboard page that includes no panels | Yes |
| `disablePrometheusExemplarSampling` | Disable Prometheus exemplar sampling | |
| `logsSampleInExplore` | Enables access to the logs sample feature in Explore | Yes |
| `disableElasticsearchBackendQuerying` | Disable the processing of queries and responses in the Elasticsearch data source through backend | |
## Beta feature toggles
| Feature toggle name | Description |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `trimDefaults` | Use cue schema to remove values that will be applied automatically |
| `panelTitleSearch` | Search for dashboards using panel title |
| `prometheusAzureOverrideAudience` | Experimental. Allow override default AAD audience for Azure Prometheus endpoint |
| `migrationLocking` | Lock database during migrations |
| `newDBLibrary` | Use jmoiron/sqlx rather than xorm for a few backend services |
| `validateDashboardsOnSave` | Validate dashboard JSON POSTed to api/dashboards/db |
| `autoMigrateOldPanels` | Migrate old angular panels to supported versions (graph, table-old, worldmap, etc) |
| `disableAngular` | Dynamic flag to disable angular at runtime. The preferred method is to set `angular_support_enabled` to `false` in the [security] settings, which allows you to change the state at runtime. |
| `grpcServer` | Run the GRPC server |
| `accessControlOnCall` | Access control primitives for OnCall |
| `alertingNoNormalState` | Stop maintaining state of alerts that are not firing |
| `disableElasticsearchBackendExploreQuery` | Disable executing of Elasticsearch Explore queries trough backend |
| `renderAuthJWT` | Uses JWT-based auth for rendering instead of relying on remote cache |
| Feature toggle name | Description |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `trimDefaults` | Use cue schema to remove values that will be applied automatically |
| `panelTitleSearch` | Search for dashboards using panel title |
| `prometheusAzureOverrideAudience` | Experimental. Allow override default AAD audience for Azure Prometheus endpoint |
| `migrationLocking` | Lock database during migrations |
| `newDBLibrary` | Use jmoiron/sqlx rather than xorm for a few backend services |
| `validateDashboardsOnSave` | Validate dashboard JSON POSTed to api/dashboards/db |
| `autoMigrateOldPanels` | Migrate old angular panels to supported versions (graph, table-old, worldmap, etc) |
| `disableAngular` | Dynamic flag to disable angular at runtime. The preferred method is to set `angular_support_enabled` to `false` in the [security] settings, which allows you to change the state at runtime. |
| `grpcServer` | Run the GRPC server |
| `accessControlOnCall` | Access control primitives for OnCall |
| `alertingNoNormalState` | Stop maintaining state of alerts that are not firing |
| `renderAuthJWT` | Uses JWT-based auth for rendering instead of relying on remote cache |
## Alpha feature toggles
@ -82,7 +82,6 @@ Alpha features might be changed or removed without prior notice.
| `athenaAsyncQueryDataSupport` | Enable async query data support for Athena |
| `showDashboardValidationWarnings` | Show warnings when dashboards do not validate against the schema |
| `mysqlAnsiQuotes` | Use double quotes to escape keyword in a MySQL query |
| `elasticsearchBackendMigration` | Use Elasticsearch as backend data source |
| `showTraceId` | Show trace ids for requests |
| `datasourceOnboarding` | Enable data source onboarding page |
| `secureSocksDatasourceProxy` | Enable secure socks tunneling for supported core datasources |

View File

@ -63,7 +63,6 @@ export interface FeatureToggles {
accessControlOnCall?: boolean;
nestedFolders?: boolean;
accessTokenExpirationCheck?: boolean;
elasticsearchBackendMigration?: boolean;
showTraceId?: boolean;
datasourceOnboarding?: boolean;
emptyDashboardPage?: boolean;
@ -86,7 +85,6 @@ export interface FeatureToggles {
prometheusResourceBrowserCache?: boolean;
influxdbBackendMigration?: boolean;
clientTokenRotation?: boolean;
disableElasticsearchBackendExploreQuery?: boolean;
prometheusDataplane?: boolean;
alertStateHistoryLokiSecondary?: boolean;
alertStateHistoryLokiPrimary?: boolean;
@ -96,4 +94,5 @@ export interface FeatureToggles {
pyroscopeFlameGraph?: boolean;
externalServiceAuth?: boolean;
dataplaneFrontendFallback?: boolean;
disableElasticsearchBackendQuerying?: boolean;
}

View File

@ -303,12 +303,6 @@ var (
State: FeatureStateStable,
Owner: grafanaAuthnzSquad,
},
{
Name: "elasticsearchBackendMigration",
Description: "Use Elasticsearch as backend data source",
State: FeatureStateAlpha,
Owner: grafanaObservabilityLogsSquad,
},
{
Name: "showTraceId",
Description: "Show trace ids for requests",
@ -457,12 +451,6 @@ var (
State: FeatureStateAlpha,
Owner: grafanaAuthnzSquad,
},
{
Name: "disableElasticsearchBackendExploreQuery",
Description: "Disable executing of Elasticsearch Explore queries trough backend",
State: FeatureStateBeta,
Owner: grafanaObservabilityLogsSquad,
},
{
Name: "prometheusDataplane",
Description: "Changes responses to from Prometheus to be compliant with the dataplane specification. In particular it sets the numeric Field.Name from 'Value' to the value of the `__name__` label when present.",
@ -519,5 +507,11 @@ var (
FrontendOnly: true,
Owner: grafanaObservabilityMetricsSquad,
},
{
Name: "disableElasticsearchBackendQuerying",
Description: "Disable the processing of queries and responses in the Elasticsearch data source through backend",
State: FeatureStateStable,
Owner: grafanaObservabilityLogsSquad,
},
}
)

View File

@ -44,7 +44,6 @@ mysqlAnsiQuotes,alpha,@grafana/backend-platform,false,false,false,false
accessControlOnCall,beta,@grafana/grafana-authnz-team,false,false,false,false
nestedFolders,alpha,@grafana/backend-platform,true,false,false,false
accessTokenExpirationCheck,stable,@grafana/grafana-authnz-team,false,false,false,false
elasticsearchBackendMigration,alpha,@grafana/observability-logs,false,false,false,false
showTraceId,alpha,@grafana/observability-logs,false,false,false,false
datasourceOnboarding,alpha,@grafana/dashboards-squad,false,false,false,false
emptyDashboardPage,stable,@grafana/dashboards-squad,false,false,false,true
@ -67,7 +66,6 @@ timeSeriesTable,alpha,@grafana/app-o11y,false,false,false,true
prometheusResourceBrowserCache,alpha,@grafana/observability-metrics,false,false,false,true
influxdbBackendMigration,alpha,@grafana/observability-metrics,false,false,false,true
clientTokenRotation,alpha,@grafana/grafana-authnz-team,false,false,false,false
disableElasticsearchBackendExploreQuery,beta,@grafana/observability-logs,false,false,false,false
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
@ -77,3 +75,4 @@ renderAuthJWT,beta,@grafana/grafana-as-code,false,false,false,false
pyroscopeFlameGraph,alpha,@grafana/observability-traces-and-profiling,false,false,false,false
externalServiceAuth,alpha,@grafana/grafana-authnz-team,true,false,false,false
dataplaneFrontendFallback,alpha,@grafana/observability-metrics,false,false,false,true
disableElasticsearchBackendQuerying,stable,@grafana/observability-logs,false,false,false,false

1 Name State Owner requiresDevMode RequiresLicense RequiresRestart FrontendOnly
44 accessControlOnCall beta @grafana/grafana-authnz-team false false false false
45 nestedFolders alpha @grafana/backend-platform true false false false
46 accessTokenExpirationCheck stable @grafana/grafana-authnz-team false false false false
elasticsearchBackendMigration alpha @grafana/observability-logs false false false false
47 showTraceId alpha @grafana/observability-logs false false false false
48 datasourceOnboarding alpha @grafana/dashboards-squad false false false false
49 emptyDashboardPage stable @grafana/dashboards-squad false false false true
66 prometheusResourceBrowserCache alpha @grafana/observability-metrics false false false true
67 influxdbBackendMigration alpha @grafana/observability-metrics false false false true
68 clientTokenRotation alpha @grafana/grafana-authnz-team false false false false
disableElasticsearchBackendExploreQuery beta @grafana/observability-logs false false false false
69 prometheusDataplane alpha @grafana/observability-metrics false false false false
70 alertStateHistoryLokiSecondary alpha @grafana/alerting-squad false false false false
71 alertStateHistoryLokiPrimary alpha @grafana/alerting-squad false false false false
75 pyroscopeFlameGraph alpha @grafana/observability-traces-and-profiling false false false false
76 externalServiceAuth alpha @grafana/grafana-authnz-team true false false false
77 dataplaneFrontendFallback alpha @grafana/observability-metrics false false false true
78 disableElasticsearchBackendQuerying stable @grafana/observability-logs false false false false

View File

@ -187,10 +187,6 @@ const (
// Enable OAuth access_token expiration check and token refresh using the refresh_token
FlagAccessTokenExpirationCheck = "accessTokenExpirationCheck"
// FlagElasticsearchBackendMigration
// Use Elasticsearch as backend data source
FlagElasticsearchBackendMigration = "elasticsearchBackendMigration"
// FlagShowTraceId
// Show trace ids for requests
FlagShowTraceId = "showTraceId"
@ -279,10 +275,6 @@ const (
// Replaces the current in-request token rotation so that the client initiates the rotation
FlagClientTokenRotation = "clientTokenRotation"
// FlagDisableElasticsearchBackendExploreQuery
// Disable executing of Elasticsearch Explore queries trough backend
FlagDisableElasticsearchBackendExploreQuery = "disableElasticsearchBackendExploreQuery"
// FlagPrometheusDataplane
// Changes responses to from Prometheus to be compliant with the dataplane specification. In particular it sets the numeric Field.Name from 'Value' to the value of the `__name__` label when present.
FlagPrometheusDataplane = "prometheusDataplane"
@ -318,4 +310,8 @@ const (
// FlagDataplaneFrontendFallback
// Support dataplane contract field name change for transformations and field name matchers where the name is different
FlagDataplaneFrontendFallback = "dataplaneFrontendFallback"
// FlagDisableElasticsearchBackendQuerying
// Disable the processing of queries and responses in the Elasticsearch data source through backend
FlagDisableElasticsearchBackendQuerying = "disableElasticsearchBackendQuerying"
)

View File

@ -43,6 +43,12 @@ jest.mock('@grafana/runtime', () => ({
},
};
},
config: {
buildInfo: {},
featureToggles: {
disableElasticsearchBackendQuerying: true,
},
},
}));
const TIMESRV_START = [2022, 8, 21, 6, 10, 10];

View File

@ -501,8 +501,8 @@ export class ElasticDatasource
}
getLogRowContext = async (row: LogRowModel, options?: RowContextOptions): Promise<{ data: DataFrame[] }> => {
const { disableElasticsearchBackendExploreQuery, elasticsearchBackendMigration } = config.featureToggles;
if (!disableElasticsearchBackendExploreQuery || elasticsearchBackendMigration) {
const { disableElasticsearchBackendQuerying } = config.featureToggles;
if (!disableElasticsearchBackendQuerying) {
const contextRequest = this.makeLogContextDataRequest(row, options);
return lastValueFrom(
@ -679,13 +679,8 @@ export class ElasticDatasource
}
query(request: DataQueryRequest<ElasticsearchQuery>): Observable<DataQueryResponse> {
// Run request through backend if it is coming from Explore and disableElasticsearchBackendExploreQuery is not set
// or if elasticsearchBackendMigration feature toggle is enabled
const { elasticsearchBackendMigration, disableElasticsearchBackendExploreQuery } = config.featureToggles;
const shouldRunTroughBackend =
(request.app === CoreApp.Explore && !disableElasticsearchBackendExploreQuery) || elasticsearchBackendMigration;
if (shouldRunTroughBackend) {
const { disableElasticsearchBackendQuerying } = config.featureToggles;
if (!disableElasticsearchBackendQuerying) {
const start = new Date();
return super.query(request).pipe(tap((response) => trackQuery(response, request, start)));
}