mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-15 01:33:54 +00:00
fix query labels
This commit is contained in:
parent
372557ff40
commit
3bc2011a78
@ -298,12 +298,13 @@ export function useQueryPodsMetrics(
|
|||||||
};
|
};
|
||||||
let labelStr = "";
|
let labelStr = "";
|
||||||
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
||||||
|
const c = config.metricConfig[idx] || {};
|
||||||
variables.push(`$labels${index}${idx}: [String!]!`);
|
variables.push(`$labels${index}${idx}: [String!]!`);
|
||||||
labelStr = `labels: $labels${index}${idx}, `;
|
labelStr = `labels: $labels${index}${idx}, `;
|
||||||
conditions[`labels${index}${idx}`] = (
|
const labels = (c.labelsIndex || "")
|
||||||
(config.metricConfig[idx] && config.metricConfig[idx].label) ||
|
.split(",")
|
||||||
""
|
.map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
).split(",");
|
conditions[`labels${index}${idx}`] = labels;
|
||||||
}
|
}
|
||||||
return `${name}${index}${idx}: ${metricType}(condition: $condition${index}${idx}, ${labelStr}duration: $duration)${RespFields[metricType]}`;
|
return `${name}${index}${idx}: ${metricType}(condition: $condition${index}${idx}, ${labelStr}duration: $duration)${RespFields[metricType]}`;
|
||||||
});
|
});
|
||||||
@ -368,28 +369,47 @@ export function usePodsSource(
|
|||||||
config.metricTypes[index] === MetricQueryTypes.ReadLabeledMetricsValues
|
config.metricTypes[index] === MetricQueryTypes.ReadLabeledMetricsValues
|
||||||
) {
|
) {
|
||||||
const resVal = resp.data[key] || [];
|
const resVal = resp.data[key] || [];
|
||||||
|
const labels = (c.label || "")
|
||||||
|
.split(",")
|
||||||
|
.map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
|
const labelsIdx = (c.labelsIndex || "")
|
||||||
|
.split(",")
|
||||||
|
.map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
for (let i = 0; i < resVal.length; i++) {
|
for (let i = 0; i < resVal.length; i++) {
|
||||||
const item = resVal[i];
|
const item = resVal[i];
|
||||||
const values = item.values.values.map((d: { value: number }) =>
|
const values = item.values.values.map((d: { value: number }) =>
|
||||||
aggregation(Number(d.value), c)
|
aggregation(Number(d.value), c)
|
||||||
);
|
);
|
||||||
if (
|
const indexNum = labelsIdx.findIndex((d: string) => d === item.label);
|
||||||
[
|
if (labels[indexNum] && indexNum > -1) {
|
||||||
Calculations.Average,
|
if (!d[labels[indexNum]]) {
|
||||||
Calculations.ApdexAvg,
|
d[labels[indexNum]] = {};
|
||||||
Calculations.PercentageAvg,
|
}
|
||||||
].includes(c.calculation)
|
if (
|
||||||
) {
|
[
|
||||||
|
Calculations.Average,
|
||||||
|
Calculations.ApdexAvg,
|
||||||
|
Calculations.PercentageAvg,
|
||||||
|
].includes(c.calculation)
|
||||||
|
) {
|
||||||
|
d[labels[indexNum]]["avg"] = calculateExp(item.values.values, c);
|
||||||
|
}
|
||||||
|
d[labels[indexNum]]["values"] = values;
|
||||||
|
} else {
|
||||||
if (!d[item.label]) {
|
if (!d[item.label]) {
|
||||||
d[item.label] = {};
|
d[item.label] = {};
|
||||||
}
|
}
|
||||||
d[item.label]["avg"] = calculateExp(item.values.values, c);
|
if (
|
||||||
|
[
|
||||||
|
Calculations.Average,
|
||||||
|
Calculations.ApdexAvg,
|
||||||
|
Calculations.PercentageAvg,
|
||||||
|
].includes(c.calculation)
|
||||||
|
) {
|
||||||
|
d[item.label]["avg"] = calculateExp(item.values.values, c);
|
||||||
|
}
|
||||||
|
d[item.label]["values"] = values;
|
||||||
}
|
}
|
||||||
if (!d[item.label]) {
|
|
||||||
d[item.label] = {};
|
|
||||||
}
|
|
||||||
d[item.label]["values"] = values;
|
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
names.push(item.label);
|
names.push(item.label);
|
||||||
metricConfigArr.push({ ...c, index: i });
|
metricConfigArr.push({ ...c, index: i });
|
||||||
|
Loading…
Reference in New Issue
Block a user