This commit is contained in:
Fine 2022-10-27 20:00:16 +08:00
parent 6a1d6e555c
commit 9dbca48ea3
2 changed files with 16 additions and 6 deletions

View File

@ -331,6 +331,7 @@ export function usePodsSource(
return {};
}
const names: string[] = [];
const metricConfigArr: MetricConfigOpt[] = config.metricConfig || [];
const data = pods.map((d: Instance | any, idx: number) => {
config.metrics.map((name: string, index: number) => {
const c: any = (config.metricConfig && config.metricConfig[index]) || {};
@ -369,7 +370,6 @@ export function usePodsSource(
const labelsIdx = (c.labelsIndex || "")
.split(",")
.map((item: string) => item.replace(/^\s*|\s*$/g, ""));
console.log(resVal);
for (const item of resVal) {
const values = item.values.values.map((d: { value: number }) =>
aggregation(Number(d.value), c)
@ -411,12 +411,13 @@ export function usePodsSource(
names.push(item.label);
}
}
metricConfigArr.splice(index, 0, c);
}
}
});
return d;
});
return { data, names };
return { data, names, metricConfigArr };
}
export function useQueryTopologyMetrics(metrics: string[], ids: string[]) {
const appStore = useAppStoreWithOut();

View File

@ -217,12 +217,21 @@ async function queryServiceMetrics(currentServices: Service[]) {
if (!metricConfig.value.length) {
return;
}
const { data, names } = usePodsSource(currentServices, json, {
...props.config,
metricConfig: metricConfig.value,
});
const { data, names, metricConfigArr } = usePodsSource(
currentServices,
json,
{
...props.config,
metricConfig: metricConfig.value,
}
);
services.value = data;
colMetrics.value = names;
// metricConfig.value = metricConfigArr;
console.log(names);
console.log(data);
console.log(metricConfigArr);
return;
}
services.value = currentServices;