From 18b39967fc73eea3fbed21e4d92049be5f1e091c Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 17 Dec 2018 16:44:57 +0100 Subject: [PATCH 1/3] enable goto explore from query panel editor for all datasources --- public/app/core/utils/explore.ts | 17 ++++++++++++----- public/app/features/panel/metrics_panel_ctrl.ts | 7 +------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index 26b6a527d95..4bb9cde3cea 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -57,12 +57,19 @@ export async function getExploreUrl( } } - if (exploreDatasource && exploreDatasource.meta.explore) { + if (panelDatasource) { const range = timeSrv.timeRangeForUrl(); - const state = { - ...exploreDatasource.getExploreState(exploreTargets), - range, - }; + let state: Partial = { range }; + if (exploreDatasource.getExploreState) { + state = { ...state, ...exploreDatasource.getExploreState(exploreTargets) }; + } else { + state = { + ...state, + datasource: panelDatasource.name, + queries: exploreTargets.map(t => ({ ...t, datasource: panelDatasource.name })), + }; + } + const exploreState = JSON.stringify(state); url = renderUrl('/explore', { state: exploreState }); } diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 68167447222..6754d27bd64 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -233,12 +233,7 @@ class MetricsPanelCtrl extends PanelCtrl { getAdditionalMenuItems() { const items = []; - if ( - config.exploreEnabled && - this.contextSrv.isEditor && - this.datasource && - (this.datasource.meta.explore || this.datasource.meta.id === 'mixed') - ) { + if (config.exploreEnabled && this.contextSrv.isEditor && this.datasource) { items.push({ text: 'Explore', click: 'ctrl.explore();', From 2835c4336d12f952d6f7f8e0657be52524b5f5af Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 17 Dec 2018 16:46:22 +0100 Subject: [PATCH 2/3] filter out table responses that don't have columns and rows --- public/app/core/utils/explore.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index 4bb9cde3cea..f978ec1ef8c 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -158,7 +158,9 @@ export function calculateResultsFromQueryTransactions( ); const tableResult = mergeTablesIntoModel( new TableModel(), - ...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result) + ...queryTransactions + .filter(qt => qt.resultType === 'Table' && qt.done && qt.result && qt.result.columns && qt.result.rows) + .map(qt => qt.result) ); const logsResult = datasource && datasource.mergeStreams From ad3d36e6b7f322c3163851f6dca5fc4d19d75389 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 18 Dec 2018 09:44:51 +0100 Subject: [PATCH 3/3] Make sure panel id is unique since some datasources (Graphite) will cancel ongoing requests with the same panel id --- public/app/features/explore/Explore.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index adfe9c7ca76..d2a81864ed1 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -608,9 +608,11 @@ export class Explore extends React.PureComponent { // Clone range for query request // const queryRange: RawTimeRange = { ...range }; // const { from, to, raw } = this.timeSrv.timeRange(); - // 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. - const panelId = queryOptions.format; + // However, some datasources don't use `panelId + query.refId`, but only `panelId`. + // Therefore panel id has to be unique. + const panelId = `${queryOptions.format}-${query.key}`; return { interval,