Commit cc589a0d by Ryan McKinley Committed by GitHub

Inspector: find the datasource from the refId, not the metadata (#22231)

* remove datasource

* get datasoure from refId

* metrictank does not need to say the datasource
parent 131a3248
......@@ -20,10 +20,6 @@ export interface QueryResultMeta {
// Used in Explore to show limit applied to search result
limit?: number;
// HACK: save the datassource name in the meta so we can load it from the response
// we should be able to find the datasource from the refId
datasource?: string;
// DatasSource Specific Values
custom?: Record<string, any>;
}
......
......@@ -16,6 +16,7 @@ import {
toCSV,
DataQueryError,
PanelData,
DataQuery,
} from '@grafana/data';
import { config } from 'app/core/config';
......@@ -106,22 +107,25 @@ export class PanelInspector extends PureComponent<Props, State> {
return;
}
// Find the first DataSource wanting to show custom metadata
let metaDS: DataSourceApi;
const data = lastResult.series;
const error = lastResult.error;
const targets = lastResult.request?.targets;
const targets = lastResult.request?.targets || [];
const requestTime = lastResult.request?.endTime ? lastResult.request?.endTime - lastResult.request.startTime : -1;
const queries = targets ? targets.length : 0;
const dataSources = new Set(targets.map(t => t.datasource)).size;
if (data) {
// Find the first DataSource wanting to show custom metadata
if (data && targets.length) {
const queries: Record<string, DataQuery> = {};
for (const target of targets) {
queries[target.refId] = target;
}
for (const frame of data) {
const key = frame.meta?.datasource;
if (key) {
const dataSource = await getDataSourceSrv().get(key);
const q = queries[frame.refId];
if (q && frame.meta.custom) {
const dataSource = await getDataSourceSrv().get(q.datasource);
if (dataSource && dataSource.components?.MetadataInspector) {
metaDS = dataSource;
break;
......@@ -138,7 +142,7 @@ export class PanelInspector extends PureComponent<Props, State> {
tab: error ? InspectTab.Error : prevState.tab,
stats: {
requestTime,
queries,
queries: targets.length,
dataSources,
},
}));
......
......@@ -124,7 +124,6 @@ export class GraphiteDatasource extends DataSourceApi<GraphiteQuery, GraphiteOpt
// Metrictank metadata
if (s.meta) {
frame.meta = {
datasource: this.name,
custom: {
request: result.data.meta, // info for the whole request
info: s.meta, // Array of metadata
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment