From f539a70d6d090c4102f4d21912c16808d5142c2e Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Thu, 31 Oct 2024 17:58:02 +0100 Subject: [PATCH] Loki shard splitting: QOL improvements (#95602) * Scan direction: add experimental badge * Logs model: keep data when the response contains errors * SupplementaryResultError: extend behaviors * LogsVolumePanel: add custom message for partial shard data * SupplementaryResultError: add size prop * SupplementaryResultError: remove size prop and adjust sizes * Infinite scroll: disable when direction is scan * Fix lint issues * logsModel: add logs volume test * chore: unfocus test * modifyQuery: add function to add drop statement to queries * Shard query splitting: split metric queries * Shard query splitting: drop stream shard from metric queries * Fix tests * logsModel: skip coverage data when the direction is scan --- public/app/features/explore/Logs/Logs.tsx | 6 +- .../explore/Logs/LogsVolumePanelList.tsx | 15 +- .../explore/SupplementaryResultError.tsx | 46 ++-- .../logs/components/InfiniteScroll.tsx | 2 +- public/app/features/logs/logsModel.test.ts | 258 +++++++++++++++--- public/app/features/logs/logsModel.ts | 21 +- .../loki/components/LokiOptionFields.tsx | 12 +- .../datasource/loki/modifyQuery.test.ts | 39 +++ .../plugins/datasource/loki/modifyQuery.ts | 75 +++-- .../datasource/loki/queryUtils.test.ts | 101 +++++++ .../app/plugins/datasource/loki/queryUtils.ts | 19 +- .../loki/shardQuerySplitting.test.ts | 32 ++- 12 files changed, 515 insertions(+), 111 deletions(-) diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx index ceeb7772aec..d04c45fe2fb 100644 --- a/public/app/features/explore/Logs/Logs.tsx +++ b/public/app/features/explore/Logs/Logs.tsx @@ -58,6 +58,7 @@ import { LogRows } from 'app/features/logs/components/LogRows'; import { LogRowContextModal } from 'app/features/logs/components/log-context/LogRowContextModal'; import { LogLevelColor, dedupLogRows, filterLogLevels } from 'app/features/logs/logsModel'; import { getLogLevel, getLogLevelFromKey, getLogLevelInfo } from 'app/features/logs/utils'; +import { LokiQueryDirection } from 'app/plugins/datasource/loki/dataquery.gen'; import { getState } from 'app/store/store'; import { ExploreItemState, useDispatch } from 'app/types'; @@ -733,6 +734,9 @@ const UnthemedLogs: React.FunctionComponent = (props: Props) => { const filteredLogs = filterRows(logRows, hiddenLogLevels); const { dedupedRows, dedupCount } = dedupRows(filteredLogs, dedupStrategy); const navigationRange = createNavigationRange(logRows); + const infiniteScrollAvailable = !logsQueries?.some( + (query) => 'direction' in query && query.direction === LokiQueryDirection.Scan + ); return ( <> @@ -932,7 +936,7 @@ const UnthemedLogs: React.FunctionComponent = (props: Props) => { > 0; const timeoutError = isTimeoutErrorResponse(logsVolumeData); const from = dateTime(Math.max(absoluteRange.from, allLogsVolumeMaximumRange.from)); @@ -95,7 +98,7 @@ export const LogsVolumePanelList = ({ if (logsVolumeData?.state === LoadingState.Loading) { return Loading...; - } else if (timeoutError) { + } else if (timeoutError && !canShowPartialData) { return ( ); - } else if (logsVolumeData?.error !== undefined) { + } else if (logsVolumeData?.error !== undefined && !canShowPartialData) { return ; } @@ -143,6 +146,14 @@ export const LogsVolumePanelList = ({ return (
+ {timeoutError && canShowPartialData && ( + + )} {Object.keys(logVolumes).map((name, index) => { return ( { + setDismissed(true); + }, []); + + const handleRemove = dismissable ? dismiss : onRemove; + + if (dismissed) { + return null; + } + return (
- + {showButton ? ( -
+
{!isOpen ? (