mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 00:41:08 +08:00
Chore: Remove loki version hack in explore (#27966)
This commit is contained in:
@ -331,6 +331,7 @@ export enum DataSourceStatus {
|
|||||||
Disconnected,
|
Disconnected,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: not really needed but used as type in some data sources and in DataQueryRequest
|
||||||
export enum ExploreMode {
|
export enum ExploreMode {
|
||||||
Logs = 'Logs',
|
Logs = 'Logs',
|
||||||
Metrics = 'Metrics',
|
Metrics = 'Metrics',
|
||||||
|
@ -155,7 +155,7 @@ export function buildQueryTransaction(
|
|||||||
__interval_ms: { text: intervalMs, value: intervalMs },
|
__interval_ms: { text: intervalMs, value: intervalMs },
|
||||||
},
|
},
|
||||||
maxDataPoints: queryOptions.maxDataPoints,
|
maxDataPoints: queryOptions.maxDataPoints,
|
||||||
exploreMode: queryOptions.mode,
|
exploreMode: undefined,
|
||||||
liveStreaming: queryOptions.liveStreaming,
|
liveStreaming: queryOptions.liveStreaming,
|
||||||
/**
|
/**
|
||||||
* @deprecated (external API) showingGraph and showingTable are always set to true and set to true
|
* @deprecated (external API) showingGraph and showingTable are always set to true and set to true
|
||||||
|
@ -128,7 +128,6 @@ export interface SyncTimesPayload {
|
|||||||
export interface UpdateDatasourceInstancePayload {
|
export interface UpdateDatasourceInstancePayload {
|
||||||
exploreId: ExploreId;
|
exploreId: ExploreId;
|
||||||
datasourceInstance: DataSourceApi;
|
datasourceInstance: DataSourceApi;
|
||||||
version?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ToggleLogLevelPayload {
|
export interface ToggleLogLevelPayload {
|
||||||
|
@ -123,13 +123,11 @@ export function changeDatasource(
|
|||||||
const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
|
const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
|
||||||
const queries = getState().explore[exploreId].queries;
|
const queries = getState().explore[exploreId].queries;
|
||||||
const orgId = getState().user.orgId;
|
const orgId = getState().user.orgId;
|
||||||
const datasourceVersion = newDataSourceInstance.getVersion && (await newDataSourceInstance.getVersion());
|
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
updateDatasourceInstanceAction({
|
updateDatasourceInstanceAction({
|
||||||
exploreId,
|
exploreId,
|
||||||
datasourceInstance: newDataSourceInstance,
|
datasourceInstance: newDataSourceInstance,
|
||||||
version: datasourceVersion,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import {
|
|||||||
DataQuery,
|
DataQuery,
|
||||||
DataSourceApi,
|
DataSourceApi,
|
||||||
dateTime,
|
dateTime,
|
||||||
ExploreMode,
|
|
||||||
LoadingState,
|
LoadingState,
|
||||||
RawTimeRange,
|
RawTimeRange,
|
||||||
UrlQueryMap,
|
UrlQueryMap,
|
||||||
@ -99,7 +98,6 @@ describe('Explore item reducer', () => {
|
|||||||
graphResult: null,
|
graphResult: null,
|
||||||
logsResult: null,
|
logsResult: null,
|
||||||
tableResult: null,
|
tableResult: null,
|
||||||
supportedModes: [ExploreMode.Metrics, ExploreMode.Logs],
|
|
||||||
latency: 0,
|
latency: 0,
|
||||||
loading: false,
|
loading: false,
|
||||||
queryResponse: createEmptyQueryResponse(),
|
queryResponse: createEmptyQueryResponse(),
|
||||||
|
@ -3,14 +3,12 @@ import { AnyAction } from 'redux';
|
|||||||
import { PayloadAction } from '@reduxjs/toolkit';
|
import { PayloadAction } from '@reduxjs/toolkit';
|
||||||
import {
|
import {
|
||||||
DataQuery,
|
DataQuery,
|
||||||
DataSourceApi,
|
|
||||||
DefaultTimeRange,
|
DefaultTimeRange,
|
||||||
LoadingState,
|
LoadingState,
|
||||||
PanelData,
|
PanelData,
|
||||||
PanelEvents,
|
PanelEvents,
|
||||||
TimeZone,
|
TimeZone,
|
||||||
toLegacyResponseData,
|
toLegacyResponseData,
|
||||||
ExploreMode,
|
|
||||||
LogsDedupStrategy,
|
LogsDedupStrategy,
|
||||||
sortLogsResult,
|
sortLogsResult,
|
||||||
DataQueryErrorType,
|
DataQueryErrorType,
|
||||||
@ -107,7 +105,6 @@ export const makeExploreItemState = (): ExploreItemState => ({
|
|||||||
urlState: null,
|
urlState: null,
|
||||||
update: makeInitialUpdateState(),
|
update: makeInitialUpdateState(),
|
||||||
latency: 0,
|
latency: 0,
|
||||||
supportedModes: [],
|
|
||||||
isLive: false,
|
isLive: false,
|
||||||
isPaused: false,
|
isPaused: false,
|
||||||
urlReplaced: false,
|
urlReplaced: false,
|
||||||
@ -259,33 +256,14 @@ export const itemReducer = (state: ExploreItemState = makeExploreItemState(), ac
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updateDatasourceInstanceAction.match(action)) {
|
if (updateDatasourceInstanceAction.match(action)) {
|
||||||
const { datasourceInstance, version } = action.payload;
|
const { datasourceInstance } = action.payload;
|
||||||
|
|
||||||
// Custom components
|
// Custom components
|
||||||
stopQueryState(state.querySubscription);
|
stopQueryState(state.querySubscription);
|
||||||
|
|
||||||
let newMetadata = datasourceInstance.meta;
|
|
||||||
|
|
||||||
// HACK: Temporary hack for Loki datasource. Can remove when plugin.json structure is changed.
|
|
||||||
if (version && version.length && datasourceInstance.meta.name === 'Loki') {
|
|
||||||
const lokiVersionMetadata: Record<string, { metrics: boolean }> = {
|
|
||||||
v0: {
|
|
||||||
metrics: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
v1: {
|
|
||||||
metrics: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
newMetadata = { ...newMetadata, ...lokiVersionMetadata[version] };
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedDatasourceInstance = Object.assign(datasourceInstance, { meta: newMetadata });
|
|
||||||
const supportedModes = getModesForDatasource(updatedDatasourceInstance);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
datasourceInstance: updatedDatasourceInstance,
|
datasourceInstance,
|
||||||
graphResult: null,
|
graphResult: null,
|
||||||
tableResult: null,
|
tableResult: null,
|
||||||
logsResult: null,
|
logsResult: null,
|
||||||
@ -293,7 +271,6 @@ export const itemReducer = (state: ExploreItemState = makeExploreItemState(), ac
|
|||||||
queryResponse: createEmptyQueryResponse(),
|
queryResponse: createEmptyQueryResponse(),
|
||||||
loading: false,
|
loading: false,
|
||||||
queryKeys: [],
|
queryKeys: [],
|
||||||
supportedModes,
|
|
||||||
originPanelId: state.urlState && state.urlState.originPanelId,
|
originPanelId: state.urlState && state.urlState.originPanelId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -588,28 +565,6 @@ export const updateChildRefreshState = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getModesForDatasource = (dataSource: DataSourceApi): ExploreMode[] => {
|
|
||||||
const supportsGraph = dataSource.meta.metrics;
|
|
||||||
const supportsLogs = dataSource.meta.logs;
|
|
||||||
const supportsTracing = dataSource.meta.tracing;
|
|
||||||
|
|
||||||
const supportedModes: ExploreMode[] = [];
|
|
||||||
|
|
||||||
if (supportsGraph) {
|
|
||||||
supportedModes.push(ExploreMode.Metrics);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (supportsLogs) {
|
|
||||||
supportedModes.push(ExploreMode.Logs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (supportsTracing) {
|
|
||||||
supportedModes.push(ExploreMode.Tracing);
|
|
||||||
}
|
|
||||||
|
|
||||||
return supportedModes;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global Explore reducer that handles multiple Explore areas (left and right).
|
* Global Explore reducer that handles multiple Explore areas (left and right).
|
||||||
* Actions that have an `exploreId` get routed to the ExploreItemReducer.
|
* Actions that have an `exploreId` get routed to the ExploreItemReducer.
|
||||||
|
@ -14,7 +14,6 @@ import {
|
|||||||
AbsoluteTimeRange,
|
AbsoluteTimeRange,
|
||||||
GraphSeriesXY,
|
GraphSeriesXY,
|
||||||
DataFrame,
|
DataFrame,
|
||||||
ExploreMode,
|
|
||||||
ExploreUrlState,
|
ExploreUrlState,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
|
|
||||||
@ -157,7 +156,6 @@ export interface ExploreItemState {
|
|||||||
update: ExploreUpdateState;
|
update: ExploreUpdateState;
|
||||||
|
|
||||||
latency: number;
|
latency: number;
|
||||||
supportedModes: ExploreMode[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the view is in live tailing mode.
|
* If true, the view is in live tailing mode.
|
||||||
@ -197,7 +195,6 @@ export interface QueryOptions {
|
|||||||
minInterval?: string;
|
minInterval?: string;
|
||||||
maxDataPoints?: number;
|
maxDataPoints?: number;
|
||||||
liveStreaming?: boolean;
|
liveStreaming?: boolean;
|
||||||
mode?: ExploreMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryTransaction {
|
export interface QueryTransaction {
|
||||||
|
Reference in New Issue
Block a user