Add feature toggles to docs (#59483)

pull/59616/head
Mitch Seaman 3 years ago committed by GitHub
parent 5dc7b01f9d
commit 240c77bb42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 111
      docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md
  2. 38
      pkg/services/featuremgmt/registry.go
  3. 26
      pkg/services/featuremgmt/toggles_gen.go
  4. 127
      pkg/services/featuremgmt/toggles_gen_test.go

@ -0,0 +1,111 @@
---
aliases:
- /docs/grafana/latest/setup-grafana/configure-grafana/feature-toggles/
description: Learn about toggles for experimental and beta features, which you can enable or disable.
title: Configure feature toggles
weight: 150
---
<!-- DO NOT EDIT THIS PAGE, it is machine generated by running the test in -->
<!-- https://github.com/grafana/grafana/blob/main/pkg/services/featuremgmt/toggles_gen_test.go#L19 -->
# Configure feature toggles
You use feature toggles, also known as feature flags, to turn experimental or beta features on and off in Grafana. Although we do not recommend using these features in production, you can turn on feature toggles to try out new functionality in development or test environments.
This page contains a list of available feature toggles. To learn how to turn on feature toggles, refer to our [Configure Grafana documentation]({{< relref "../_index.md/#feature_toggles" >}}). Feature toggles are also available to Grafana Cloud Advanced customers. If you use Grafana Cloud Advanced, you can open a support ticket and specify the feature toggles and stack for which you want them enabled.
## Stable feature toggles
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 |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------ |
| `promQueryBuilder` | Show Prometheus query builder | Yes |
| `disableEnvelopeEncryption` | Disable envelope encryption (emergency only) | |
| `database_metrics` | Add Prometheus metrics for database tables | |
| `lokiMonacoEditor` | Access to Monaco query editor for Loki | Yes |
| `featureHighlights` | Highlight Grafana Enterprise features | |
| `commandPalette` | Enable command palette | Yes |
| `cloudWatchDynamicLabels` | Use dynamic labels instead of alias patterns in CloudWatch datasource | Yes |
| `prometheusBufferedClient` | Enable buffered (old) client for Prometheus datasource as default instead of streaming JSON parser client (new) | |
| `internationalization` | Enables internationalization | |
| `accessTokenExpirationCheck` | Enable OAuth access_token expiration check and token refresh using the refresh_token | |
## 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 |
| `swaggerUi` | Serves swagger UI |
| `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 |
| `autoMigrateGraphPanels` | Replace the angular graph panel with timeseries |
| `interFont` | Switch to inter font |
| `datasourceLogger` | Logs all datasource requests |
## Alpha feature toggles
These features are early in their development lifecycle and so are not yet supported in Grafana Cloud.
Alpha features might be changed or removed without prior notice.
| Feature toggle name | Description |
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `alertingBigTransactions` | Use big transactions for alerting database writes |
| `dashboardPreviews` | Create and show thumbnails for dashboard search results |
| `live-config` | Save Grafana Live configuration in SQL tables |
| `live-pipeline` | Enable a generic live processing pipeline |
| `live-service-web-worker` | This will use a webworker thread to processes events rather than the main thread |
| `queryOverLive` | Use Grafana Live WebSocket to execute backend queries |
| `tempoApmTable` | Show APM table |
| `influxdbBackendMigration` | Query InfluxDB InfluxQL without the proxy |
| `publicDashboards` | Enables public access to dashboards |
| `lokiLive` | Support WebSocket streaming for loki (early prototype) |
| `lokiDataframeApi` | Use experimental loki api for WebSocket streaming (early prototype) |
| `dashboardComments` | Enable dashboard-wide comments |
| `annotationComments` | Enable annotation comments |
| `storage` | Configurable storage for dashboards, datasources, and resources |
| `exploreMixedDatasource` | Enable mixed datasource in Explore |
| `tracing` | Adds trace ID to error notifications |
| `correlations` | Correlations page |
| `datasourceQueryMultiStatus` | Introduce HTTP 207 Multi Status for api/ds/query |
| `traceToMetrics` | Enable trace to metrics links |
| `prometheusWideSeries` | Enable wide series responses in the Prometheus datasource |
| `canvasPanelNesting` | Allow elements nesting |
| `scenes` | Experimental framework to build interactive dashboards |
| `disableSecretsCompatibility` | Disable duplicated secret storage in legacy tables |
| `logRequestsInstrumentedAsUnknown` | Logs the path for requests that are instrumented as unknown |
| `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. |
| `topnav` | New top nav and page layouts |
| `traceqlEditor` | Show the TraceQL editor in the explore page |
| `flameGraph` | Show the flame graph |
| `cloudWatchCrossAccountQuerying` | Use cross-account querying in CloudWatch datasource |
| `redshiftAsyncQueryDataSupport` | Enable async query data support for Redshift |
| `athenaAsyncQueryDataSupport` | Enable async query data support for Athena |
| `increaseInMemDatabaseQueryCache` | Enable more in memory caching for database queries |
| `newPanelChromeUI` | Show updated look and feel of grafana-ui PanelChrome: panel header, icons, and menu |
| `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 |
| `secureSocksDatasourceProxy` | Enable secure socks tunneling for supported core datasources |
| `authnService` | Use new auth service to perform authentication |
## Development feature toggles
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 |
| -------------------------------------- | --------------------------------------------------------- |
| `dashboardPreviewsAdmin` | Manage the dashboard previews crawler process from the UI |
| `showFeatureFlagsInUI` | Show feature flags in the settings UI |
| `dashboardsFromStorage` | Load dashboards from the generic storage interface |
| `export` | Export grafana instance (to git, etc) |
| `azureMonitorResourcePickerForMetrics` | New UI for Azure Monitor Metrics Query |
| `grpcServer` | Run GRPC server |
| `objectStore` | SQL-based object store |
| `queryLibrary` | Reusable query library |
| `accessControlOnCall` | Access control primitives for OnCall |
| `nestedFolders` | Enable folder nesting |

@ -16,7 +16,7 @@ var (
},
{
Name: "promQueryBuilder",
Description: "Show prometheus query builder",
Description: "Show Prometheus query builder",
State: FeatureStateStable,
Expression: "true", // on by default
FrontendOnly: true,
@ -33,7 +33,7 @@ var (
},
{
Name: "database_metrics",
Description: "Add prometheus metrics for database tables",
Description: "Add Prometheus metrics for database tables",
State: FeatureStateStable,
},
{
@ -49,12 +49,12 @@ var (
},
{
Name: "live-config",
Description: "Save grafana live configuration in SQL tables",
Description: "Save Grafana Live configuration in SQL tables",
State: FeatureStateAlpha,
},
{
Name: "live-pipeline",
Description: "enable a generic live processing pipeline",
Description: "Enable a generic live processing pipeline",
State: FeatureStateAlpha,
},
{
@ -65,14 +65,14 @@ var (
},
{
Name: "queryOverLive",
Description: "Use grafana live websocket to execute backend queries",
Description: "Use Grafana Live WebSocket to execute backend queries",
State: FeatureStateAlpha,
FrontendOnly: true,
},
{
Name: "panelTitleSearch",
Description: "Search for dashboards using panel title",
State: FeatureStateAlpha,
State: FeatureStateBeta,
},
{
Name: "tempoApmTable",
@ -99,23 +99,23 @@ var (
},
{
Name: "publicDashboards",
Description: "enables public access to dashboards",
Description: "Enables public access to dashboards",
State: FeatureStateAlpha,
},
{
Name: "lokiLive",
Description: "support websocket streaming for loki (early prototype)",
Description: "Support WebSocket streaming for loki (early prototype)",
State: FeatureStateAlpha,
},
{
Name: "lokiDataframeApi",
Description: "use experimental loki api for websocket streaming (early prototype)",
Description: "Use experimental loki api for WebSocket streaming (early prototype)",
State: FeatureStateAlpha,
},
{
Name: "lokiMonacoEditor",
Description: "Access to Monaco query editor for Loki",
State: FeatureStateAlpha,
State: FeatureStateStable,
Expression: "true",
FrontendOnly: true,
},
@ -126,7 +126,7 @@ var (
},
{
Name: "featureHighlights",
Description: "Highlight Enterprise features",
Description: "Highlight Grafana Enterprise features",
State: FeatureStateStable,
},
{
@ -222,7 +222,7 @@ var (
{
Name: "validateDashboardsOnSave",
Description: "Validate dashboard JSON POSTed to api/dashboards/db",
State: FeatureStateAlpha,
State: FeatureStateBeta,
RequiresRestart: true,
},
{
@ -257,10 +257,11 @@ var (
{
Name: "logRequestsInstrumentedAsUnknown",
Description: "Logs the path for requests that are instrumented as unknown",
State: FeatureStateAlpha,
},
{
Name: "dataConnectionsConsole",
Description: "Enables a new top-level page called Connections. This page is an experiment for better grouping of installing / configuring data sources and other plugins.",
Description: "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.",
State: FeatureStateAlpha,
},
{
@ -281,7 +282,7 @@ var (
},
{
Name: "objectStore",
Description: "SQL based object store",
Description: "SQL-based object store",
State: FeatureStateAlpha,
RequiresDevMode: true,
},
@ -315,10 +316,12 @@ var (
{
Name: "increaseInMemDatabaseQueryCache",
Description: "Enable more in memory caching for database queries",
State: FeatureStateAlpha,
},
{
Name: "interFont",
Description: "Switch to inter font",
State: FeatureStateBeta,
},
{
Name: "newPanelChromeUI",
@ -334,16 +337,18 @@ var (
},
{
Name: "showDashboardValidationWarnings",
Description: "Show warnings when Dashboards do not validate against the schema",
Description: "Show warnings when dashboards do not validate against the schema",
State: FeatureStateAlpha,
},
{
Name: "mysqlAnsiQuotes",
Description: "Use double quote to escape keyword in Mysql query",
Description: "Use double quotes to escape keyword in a MySQL query",
State: FeatureStateAlpha,
},
{
Name: "datasourceLogger",
Description: "Logs all datasource requests",
State: FeatureStateBeta,
},
{
Name: "accessControlOnCall",
@ -370,6 +375,7 @@ var (
{
Name: "secureSocksDatasourceProxy",
Description: "Enable secure socks tunneling for supported core datasources",
State: FeatureStateAlpha,
},
{
Name: "authnService",

@ -12,7 +12,7 @@ const (
FlagAlertingBigTransactions = "alertingBigTransactions"
// FlagPromQueryBuilder
// Show prometheus query builder
// Show Prometheus query builder
FlagPromQueryBuilder = "promQueryBuilder"
// FlagTrimDefaults
@ -24,7 +24,7 @@ const (
FlagDisableEnvelopeEncryption = "disableEnvelopeEncryption"
// FlagDatabaseMetrics
// Add prometheus metrics for database tables
// Add Prometheus metrics for database tables
FlagDatabaseMetrics = "database_metrics"
// FlagDashboardPreviews
@ -36,11 +36,11 @@ const (
FlagDashboardPreviewsAdmin = "dashboardPreviewsAdmin"
// FlagLiveConfig
// Save grafana live configuration in SQL tables
// Save Grafana Live configuration in SQL tables
FlagLiveConfig = "live-config"
// FlagLivePipeline
// enable a generic live processing pipeline
// Enable a generic live processing pipeline
FlagLivePipeline = "live-pipeline"
// FlagLiveServiceWebWorker
@ -48,7 +48,7 @@ const (
FlagLiveServiceWebWorker = "live-service-web-worker"
// FlagQueryOverLive
// Use grafana live websocket to execute backend queries
// Use Grafana Live WebSocket to execute backend queries
FlagQueryOverLive = "queryOverLive"
// FlagPanelTitleSearch
@ -72,15 +72,15 @@ const (
FlagShowFeatureFlagsInUI = "showFeatureFlagsInUI"
// FlagPublicDashboards
// enables public access to dashboards
// Enables public access to dashboards
FlagPublicDashboards = "publicDashboards"
// FlagLokiLive
// support websocket streaming for loki (early prototype)
// Support WebSocket streaming for loki (early prototype)
FlagLokiLive = "lokiLive"
// FlagLokiDataframeApi
// use experimental loki api for websocket streaming (early prototype)
// Use experimental loki api for WebSocket streaming (early prototype)
FlagLokiDataframeApi = "lokiDataframeApi"
// FlagLokiMonacoEditor
@ -92,7 +92,7 @@ const (
FlagSwaggerUi = "swaggerUi"
// FlagFeatureHighlights
// Highlight Enterprise features
// Highlight Grafana Enterprise features
FlagFeatureHighlights = "featureHighlights"
// FlagDashboardComments
@ -188,7 +188,7 @@ const (
FlagLogRequestsInstrumentedAsUnknown = "logRequestsInstrumentedAsUnknown"
// FlagDataConnectionsConsole
// Enables a new top-level page called Connections. This page is an experiment for better grouping of installing / configuring data sources and other plugins.
// 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.
FlagDataConnectionsConsole = "dataConnectionsConsole"
// FlagInternationalization
@ -204,7 +204,7 @@ const (
FlagGrpcServer = "grpcServer"
// FlagObjectStore
// SQL based object store
// SQL-based object store
FlagObjectStore = "objectStore"
// FlagTraceqlEditor
@ -244,11 +244,11 @@ const (
FlagQueryLibrary = "queryLibrary"
// FlagShowDashboardValidationWarnings
// Show warnings when Dashboards do not validate against the schema
// Show warnings when dashboards do not validate against the schema
FlagShowDashboardValidationWarnings = "showDashboardValidationWarnings"
// FlagMysqlAnsiQuotes
// Use double quote to escape keyword in Mysql query
// Use double quotes to escape keyword in a MySQL query
FlagMysqlAnsiQuotes = "mysqlAnsiQuotes"
// FlagDatasourceLogger

@ -11,6 +11,7 @@ import (
"unicode"
"github.com/google/go-cmp/cmp"
"github.com/olekukonko/tablewriter"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/services/featuremgmt/strcase"
@ -26,6 +27,20 @@ func TestFeatureToggleFiles(t *testing.T) {
"live-service-web-worker": true,
}
t.Run("check registry constraints", func(t *testing.T) {
for _, flag := range standardFeatureFlags {
if flag.Expression == "true" && flag.State != FeatureStateStable {
t.Errorf("only stable features can be enabled by default. See: %s", flag.Name)
}
if flag.RequiresDevMode && flag.State != FeatureStateAlpha {
t.Errorf("only alpha features can require dev mode. See: %s", flag.Name)
}
if flag.State == FeatureStateUnknown {
t.Errorf("standard toggles should not have an unknown state. See: %s", flag.Name)
}
}
})
t.Run("verify files", func(t *testing.T) {
// Typescript files
verifyAndGenerateFile(t,
@ -38,6 +53,12 @@ func TestFeatureToggleFiles(t *testing.T) {
"toggles_gen.go",
generateRegistry(t),
)
// Docs files
verifyAndGenerateFile(t,
"../../../docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md",
generateDocsMD(),
)
})
t.Run("check feature naming convention", func(t *testing.T) {
@ -171,3 +192,109 @@ const (`)
return buff.String()
}
func generateDocsMD() string {
hasDeprecatedFlags := false
buf := `---
aliases:
- /docs/grafana/latest/setup-grafana/configure-grafana/feature-toggles/
description: Learn about toggles for experimental and beta features, which you can enable or disable.
title: Configure feature toggles
weight: 150
---
<!-- DO NOT EDIT THIS PAGE, it is machine generated by running the test in -->
<!-- https://github.com/grafana/grafana/blob/main/pkg/services/featuremgmt/toggles_gen_test.go#L19 -->
# Configure feature toggles
You use feature toggles, also known as feature flags, to turn experimental or beta features on and off in Grafana. Although we do not recommend using these features in production, you can turn on feature toggles to try out new functionality in development or test environments.
This page contains a list of available feature toggles. To learn how to turn on feature toggles, refer to our [Configure Grafana documentation]({{< relref "../_index.md/#feature_toggles" >}}). Feature toggles are also available to Grafana Cloud Advanced customers. If you use Grafana Cloud Advanced, you can open a support ticket and specify the feature toggles and stack for which you want them enabled.
## Stable feature toggles
Some stable features are enabled by default. You can disable a stable feature by setting the feature flag to "false" in the configuration.
` + writeToggleDocsTable(func(flag FeatureFlag) bool {
return flag.State == FeatureStateStable
}, true)
buf += `
## Beta feature toggles
` + writeToggleDocsTable(func(flag FeatureFlag) bool {
return flag.State == FeatureStateBeta
}, false)
if hasDeprecatedFlags {
buf += `
## Deprecated feature toggles
When stable or beta features are slated for removal, they will be marked as Deprecated first.
` + writeToggleDocsTable(func(flag FeatureFlag) bool {
return flag.State == FeatureStateDeprecated
}, false)
}
buf += `
## Alpha feature toggles
These features are early in their development lifecycle and so are not yet supported in Grafana Cloud.
Alpha features might be changed or removed without prior notice.
` + writeToggleDocsTable(func(flag FeatureFlag) bool {
return flag.State == FeatureStateAlpha && !flag.RequiresDevMode
}, false)
buf += `
## Development feature toggles
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.
` + writeToggleDocsTable(func(flag FeatureFlag) bool {
return flag.RequiresDevMode
}, false)
return buf
}
func writeToggleDocsTable(include func(FeatureFlag) bool, showEnableByDefault bool) string {
data := [][]string{}
for _, flag := range standardFeatureFlags {
if include(flag) {
row := []string{"`" + flag.Name + "`", flag.Description}
if showEnableByDefault {
on := ""
if flag.Expression == "true" {
on = "Yes"
}
row = append(row, on)
}
data = append(data, row)
}
}
header := []string{"Feature toggle name", "Description"}
if showEnableByDefault {
header = append(header, "Enabled by default")
}
sb := &strings.Builder{}
table := tablewriter.NewWriter(sb)
table.SetHeader(header)
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
table.SetAutoFormatHeaders(false)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table.SetAutoWrapText(false)
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.AppendBulk(data) // Add Bulk Data
table.Render()
// Markdown table formatting (from prittier)
v := strings.ReplaceAll(sb.String(), "|--", "| -")
return strings.ReplaceAll(v, "--|", "- |")
}

Loading…
Cancel
Save