From 840aeddbd1957117d9b62074c155e87bb4afd4b4 Mon Sep 17 00:00:00 2001 From: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> Date: Thu, 2 May 2024 10:28:15 -0500 Subject: [PATCH] Logs: Explore panel default visualization feature flag (#87189) * add logsExploreTableDefaultVisualization feature flag * use feature flag in calculating initial visualization type * add feature flag to tracking --- .../configure-grafana/feature-toggles/index.md | 1 + .../grafana-data/src/types/featureToggles.gen.ts | 1 + pkg/services/featuremgmt/registry.go | 7 +++++++ pkg/services/featuremgmt/toggles_gen.csv | 1 + pkg/services/featuremgmt/toggles_gen.go | 4 ++++ pkg/services/featuremgmt/toggles_gen.json | 16 ++++++++++++++++ public/app/features/explore/Logs/Logs.tsx | 7 +++++++ public/app/features/explore/state/query.ts | 1 + 8 files changed, 38 insertions(+) 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 4355d81c5c8..a3ff64c757b 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -177,6 +177,7 @@ Experimental features might be changed or removed without prior notice. | `accessActionSets` | Introduces action sets for resource permissions | | `disableNumericMetricsSortingInExpressions` | In server-side expressions, disable the sorting of numeric-kind metrics by their metric name or labels. | | `queryLibrary` | Enables Query Library feature in Explore | +| `logsExploreTableDefaultVisualization` | Sets the logs table as default visualisation in logs explore | ## Development feature toggles diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 7fbc72bfdf3..7b1da776335 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -181,4 +181,5 @@ export interface FeatureToggles { disableNumericMetricsSortingInExpressions?: boolean; grafanaManagedRecordingRules?: boolean; queryLibrary?: boolean; + logsExploreTableDefaultVisualization?: boolean; } diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 894b1a79238..81a1a34ae97 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -1220,6 +1220,13 @@ var ( FrontendOnly: false, AllowSelfServe: false, }, + { + Name: "logsExploreTableDefaultVisualization", + Description: "Sets the logs table as default visualisation in logs explore", + Stage: FeatureStageExperimental, + Owner: grafanaObservabilityLogsSquad, + FrontendOnly: true, + }, } ) diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index f7cf6c559d9..62a586a1264 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -162,3 +162,4 @@ accessActionSets,experimental,@grafana/identity-access-team,false,false,false disableNumericMetricsSortingInExpressions,experimental,@grafana/observability-metrics,false,true,false grafanaManagedRecordingRules,experimental,@grafana/alerting-squad,false,false,false queryLibrary,experimental,@grafana/explore-squad,false,false,false +logsExploreTableDefaultVisualization,experimental,@grafana/observability-logs,false,false,true diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 658e9d58dbd..cd95d4af1ac 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -658,4 +658,8 @@ const ( // FlagQueryLibrary // Enables Query Library feature in Explore FlagQueryLibrary = "queryLibrary" + + // FlagLogsExploreTableDefaultVisualization + // Sets the logs table as default visualisation in logs explore + FlagLogsExploreTableDefaultVisualization = "logsExploreTableDefaultVisualization" ) diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index 45b3960078e..cea7df0e92d 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -2106,6 +2106,22 @@ "stage": "experimental", "codeowner": "@grafana/explore-squad" } + }, + { + "metadata": { + "name": "logsExploreTableDefaultVisualization", + "resourceVersion": "1714583478121", + "creationTimestamp": "2024-05-01T17:05:57Z", + "annotations": { + "grafana.app/updatedTimestamp": "2024-05-01 17:11:18.121837 +0000 UTC" + } + }, + "spec": { + "description": "Sets the logs table as default visualisation in logs explore", + "stage": "experimental", + "codeowner": "@grafana/observability-logs", + "frontend": true + } } ] } \ No newline at end of file diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx index c5faf08dc5a..0a5e9542565 100644 --- a/public/app/features/explore/Logs/Logs.tsx +++ b/public/app/features/explore/Logs/Logs.tsx @@ -144,6 +144,12 @@ const getDefaultVisualisationType = (): LogsVisualisationType => { if (visualisationType === 'table') { return 'table'; } + if (visualisationType === 'logs') { + return 'logs'; + } + if (config.featureToggles.logsExploreTableDefaultVisualization) { + return 'table'; + } return 'logs'; }; @@ -290,6 +296,7 @@ class UnthemedLogs extends PureComponent { reportInteraction('grafana_explore_logs_visualisation_changed', { newVisualizationType: visualisation, datasourceType: this.props.datasourceType ?? 'unknown', + defaultVisualisationType: config.featureToggles.logsExploreTableDefaultVisualization ? 'table' : 'logs', }); }; diff --git a/public/app/features/explore/state/query.ts b/public/app/features/explore/state/query.ts index 4aa94686a76..3a05fdc13f0 100644 --- a/public/app/features/explore/state/query.ts +++ b/public/app/features/explore/state/query.ts @@ -665,6 +665,7 @@ export const runQueries = createAsyncThunk( visualisationType: exploreState?.panelsState?.logs?.visualisationType ?? store.get(visualisationTypeKey) ?? 'N/A', length: data.logsResult.rows.length, + defaultVisualisationType: config.featureToggles.logsExploreTableDefaultVisualization ? 'table' : 'logs', }); } dispatch(queryStreamUpdatedAction({ exploreId, response: data }));