|
|
|
@ -17,7 +17,7 @@ import { LoadingState } from '@grafana/schema'; |
|
|
|
|
import { LokiDatasource } from './datasource'; |
|
|
|
|
import { splitTimeRange as splitLogsTimeRange } from './logsTimeSplitting'; |
|
|
|
|
import { splitTimeRange as splitMetricTimeRange } from './metricTimeSplitting'; |
|
|
|
|
import { isLogsQuery, isQueryWithDistinct } from './queryUtils'; |
|
|
|
|
import { isLogsQuery, isQueryWithDistinct, isQueryWithRangeVariable } from './queryUtils'; |
|
|
|
|
import { combineResponses } from './responseUtils'; |
|
|
|
|
import { trackGroupedQueries } from './tracking'; |
|
|
|
|
import { LokiGroupedRequest, LokiQuery, LokiQueryType } from './types'; |
|
|
|
@ -213,13 +213,19 @@ function getNextRequestPointers(requests: LokiGroupedRequest[], requestGroup: nu |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function querySupporstSplitting(query: LokiQuery) { |
|
|
|
|
return query.queryType !== LokiQueryType.Instant && !isQueryWithDistinct(query.expr); |
|
|
|
|
function querySupportsSplitting(query: LokiQuery) { |
|
|
|
|
return ( |
|
|
|
|
query.queryType !== LokiQueryType.Instant && |
|
|
|
|
!isQueryWithDistinct(query.expr) && |
|
|
|
|
// Queries with $__range variable should not be split because then the interpolated $__range variable is incorrect
|
|
|
|
|
// because it is interpolated on the backend with the split timeRange
|
|
|
|
|
!isQueryWithRangeVariable(query.expr) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function runSplitQuery(datasource: LokiDatasource, request: DataQueryRequest<LokiQuery>) { |
|
|
|
|
const queries = request.targets.filter((query) => !query.hide); |
|
|
|
|
const [nonSplittingQueries, normalQueries] = partition(queries, (query) => !querySupporstSplitting(query)); |
|
|
|
|
const [nonSplittingQueries, normalQueries] = partition(queries, (query) => !querySupportsSplitting(query)); |
|
|
|
|
const [logQueries, metricQueries] = partition(normalQueries, (query) => isLogsQuery(query.expr)); |
|
|
|
|
|
|
|
|
|
request.queryGroupId = uuidv4(); |
|
|
|
|