feat: remove metric name

This commit is contained in:
Fine 2023-06-07 14:10:40 +08:00
parent b293f4ddb5
commit 00281e8920

View File

@ -107,11 +107,11 @@ export function useExpressionsSourceProcessor(
} }
const source: { [key: string]: unknown } = {}; const source: { [key: string]: unknown } = {};
const keys = Object.keys(resp.data); const keys = Object.keys(resp.data);
for (let i = 0; i < config.metricTypes.length; i++) { for (let i = 0; i < config.metrics.length; i++) {
const type = config.metricTypes[i]; const type = config.metricTypes[i];
const c = (config.metricConfig && config.metricConfig[i]) || {}; const c: any = (config.metricConfig && config.metricConfig[i]) || {};
const results = (resp.data[keys[i]] && resp.data[keys[i]].results) || []; const results = (resp.data[keys[i]] && resp.data[keys[i]].results) || [];
const name = ((results[0] || {}).metric || {}).name; const name = config.metrics[i];
if (type === ExpressionResultType.TIME_SERIES_VALUES) { if (type === ExpressionResultType.TIME_SERIES_VALUES) {
if (results.length === 1) { if (results.length === 1) {
@ -255,7 +255,7 @@ export async function useExpressionsQueryPodsMetrics(
if (!results[0]) { if (!results[0]) {
return d; return d;
} }
const name = results[0].metric.name || ""; const name = config.expressions[index] || "";
if (!d[name]) { if (!d[name]) {
d[name] = {}; d[name] = {};
} }