|
@@ -13,21 +13,16 @@ import {
|
|
|
LogRowModel,
|
|
LogRowModel,
|
|
|
LogsModel,
|
|
LogsModel,
|
|
|
LogsDedupStrategy,
|
|
LogsDedupStrategy,
|
|
|
|
|
+ IntervalValues,
|
|
|
DefaultTimeZone,
|
|
DefaultTimeZone,
|
|
|
} from '@grafana/data';
|
|
} from '@grafana/data';
|
|
|
import { renderUrl } from 'app/core/utils/url';
|
|
import { renderUrl } from 'app/core/utils/url';
|
|
|
import store from 'app/core/store';
|
|
import store from 'app/core/store';
|
|
|
|
|
+import kbn from 'app/core/utils/kbn';
|
|
|
import { getNextRefIdChar } from './query';
|
|
import { getNextRefIdChar } from './query';
|
|
|
// Types
|
|
// Types
|
|
|
import { DataQuery, DataSourceApi, DataQueryError, DataQueryRequest, PanelModel } from '@grafana/ui';
|
|
import { DataQuery, DataSourceApi, DataQueryError, DataQueryRequest, PanelModel } from '@grafana/ui';
|
|
|
-import {
|
|
|
|
|
- ExploreUrlState,
|
|
|
|
|
- HistoryItem,
|
|
|
|
|
- QueryTransaction,
|
|
|
|
|
- QueryIntervals,
|
|
|
|
|
- QueryOptions,
|
|
|
|
|
- ExploreMode,
|
|
|
|
|
-} from 'app/types/explore';
|
|
|
|
|
|
|
+import { ExploreUrlState, HistoryItem, QueryTransaction, QueryOptions, ExploreMode } from 'app/types/explore';
|
|
|
import { config } from '../config';
|
|
import { config } from '../config';
|
|
|
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
|
|
|
|
|
@@ -103,17 +98,16 @@ export function buildQueryTransaction(
|
|
|
queries: DataQuery[],
|
|
queries: DataQuery[],
|
|
|
queryOptions: QueryOptions,
|
|
queryOptions: QueryOptions,
|
|
|
range: TimeRange,
|
|
range: TimeRange,
|
|
|
- queryIntervals: QueryIntervals,
|
|
|
|
|
scanning: boolean
|
|
scanning: boolean
|
|
|
): QueryTransaction {
|
|
): QueryTransaction {
|
|
|
- const { interval, intervalMs } = queryIntervals;
|
|
|
|
|
-
|
|
|
|
|
const configuredQueries = queries.map(query => ({ ...query, ...queryOptions }));
|
|
const configuredQueries = queries.map(query => ({ ...query, ...queryOptions }));
|
|
|
const key = queries.reduce((combinedKey, query) => {
|
|
const key = queries.reduce((combinedKey, query) => {
|
|
|
combinedKey += query.key;
|
|
combinedKey += query.key;
|
|
|
return combinedKey;
|
|
return combinedKey;
|
|
|
}, '');
|
|
}, '');
|
|
|
|
|
|
|
|
|
|
+ const { interval, intervalMs } = getIntervals(range, queryOptions.minInterval, queryOptions.maxDataPoints);
|
|
|
|
|
+
|
|
|
// Most datasource is using `panelId + query.refId` for cancellation logic.
|
|
// Most datasource is using `panelId + query.refId` for cancellation logic.
|
|
|
// Using `format` here because it relates to the view panel that the request is for.
|
|
// Using `format` here because it relates to the view panel that the request is for.
|
|
|
// However, some datasources don't use `panelId + query.refId`, but only `panelId`.
|
|
// However, some datasources don't use `panelId + query.refId`, but only `panelId`.
|
|
@@ -518,3 +512,11 @@ export const stopQueryState = (querySubscription: Unsubscribable) => {
|
|
|
querySubscription.unsubscribe();
|
|
querySubscription.unsubscribe();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+export function getIntervals(range: TimeRange, lowLimit: string, resolution: number): IntervalValues {
|
|
|
|
|
+ if (!resolution) {
|
|
|
|
|
+ return { interval: '1s', intervalMs: 1000 };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return kbn.calculateInterval(range, resolution, lowLimit);
|
|
|
|
|
+}
|