diff --git a/public/app/features/explore/Logs/Logs.test.tsx b/public/app/features/explore/Logs/Logs.test.tsx index 6f5f4eee7be..cb995300c04 100644 --- a/public/app/features/explore/Logs/Logs.test.tsx +++ b/public/app/features/explore/Logs/Logs.test.tsx @@ -18,7 +18,8 @@ import { organizeFieldsTransformer } from '@grafana/data/src/transformations/tra import { config } from '@grafana/runtime'; import { extractFieldsTransformer } from 'app/features/transformers/extractFields/extractFields'; -import { Logs, visualisationTypeKey } from './Logs'; +import { Logs } from './Logs'; +import { visualisationTypeKey } from './utils/logs'; import { getMockElasticFrame, getMockLokiFrame } from './utils/testMocks.test'; const reportInteraction = jest.fn(); diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx index 122763cc5f9..75f6160da09 100644 --- a/public/app/features/explore/Logs/Logs.tsx +++ b/public/app/features/explore/Logs/Logs.tsx @@ -62,7 +62,7 @@ import { LogsMetaRow } from './LogsMetaRow'; import LogsNavigation from './LogsNavigation'; import { getLogsTableHeight, LogsTableWrap } from './LogsTableWrap'; import { LogsVolumePanelList } from './LogsVolumePanelList'; -import { SETTINGS_KEYS } from './utils/logs'; +import { SETTINGS_KEYS, visualisationTypeKey } from './utils/logs'; interface Props extends Themeable2 { width: number; @@ -141,8 +141,6 @@ const DEDUP_OPTIONS = [ LogsDedupStrategy.signature, ]; -export const visualisationTypeKey = 'grafana.explore.logs.visualisationType'; - const getDefaultVisualisationType = (): LogsVisualisationType => { const visualisationType = store.get(visualisationTypeKey); if (visualisationType === 'table') { diff --git a/public/app/features/explore/Logs/utils/logs.ts b/public/app/features/explore/Logs/utils/logs.ts index d156da0c080..2aec91da980 100644 --- a/public/app/features/explore/Logs/utils/logs.ts +++ b/public/app/features/explore/Logs/utils/logs.ts @@ -6,3 +6,5 @@ export const SETTINGS_KEYS = { logsSortOrder: 'grafana.explore.logs.sortOrder', logContextWrapLogMessage: 'grafana.explore.logs.logContext.wrapLogMessage', }; + +export const visualisationTypeKey = 'grafana.explore.logs.visualisationType'; diff --git a/public/app/features/explore/state/query.ts b/public/app/features/explore/state/query.ts index 95924ac8527..eed6d94378f 100644 --- a/public/app/features/explore/state/query.ts +++ b/public/app/features/explore/state/query.ts @@ -23,6 +23,7 @@ import { } from '@grafana/data'; import { config, getDataSourceSrv, reportInteraction } from '@grafana/runtime'; import { DataQuery } from '@grafana/schema'; +import store from 'app/core/store'; import { buildQueryTransaction, ensureQueries, @@ -51,6 +52,7 @@ import { ExploreState, QueryOptions, SupplementaryQueries } from 'app/types/expl import { notifyApp } from '../../../core/actions'; import { createErrorNotification } from '../../../core/copy/appNotification'; import { runRequest } from '../../query/state/runRequest'; +import { visualisationTypeKey } from '../Logs/utils/logs'; import { decorateData } from '../utils/decorators'; import { getSupplementaryQueryProvider, @@ -633,17 +635,21 @@ export const runQueries = createAsyncThunk( newQuerySubscription = newQuerySource.subscribe({ next(data) { + const exploreState = getState().explore.panes[exploreId]; if (data.logsResult !== null && data.state === LoadingState.Done) { reportInteraction('grafana_explore_logs_result_displayed', { datasourceType: datasourceInstance.type, + visualisationType: + exploreState?.panelsState?.logs?.visualisationType ?? store.get(visualisationTypeKey) ?? 'N/A', + length: data.logsResult.rows.length, }); } dispatch(queryStreamUpdatedAction({ exploreId, response: data })); // Keep scanning for results if this was the last scanning transaction - if (getState().explore.panes[exploreId]!.scanning) { + if (exploreState!.scanning) { if (data.state === LoadingState.Done && data.series.length === 0) { - const range = getShiftedTimeRange(-1, getState().explore.panes[exploreId]!.range); + const range = getShiftedTimeRange(-1, exploreState!.range); dispatch(updateTime({ exploreId, absoluteRange: range })); dispatch(runQueries({ exploreId })); } else {