mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-05 21:15:23 +00:00
update
This commit is contained in:
parent
3f20f6165e
commit
8b828c523c
@ -154,7 +154,7 @@ export function useQueryProcessor(config: any) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const queryStr = `query queryData(${variables}) {${fragment}}`;
|
const queryStr = `query queryData(${variables}) {${fragment}}`;
|
||||||
console.log(queryStr);
|
|
||||||
return {
|
return {
|
||||||
queryStr,
|
queryStr,
|
||||||
conditions,
|
conditions,
|
||||||
@ -255,7 +255,11 @@ export function useSourceProcessor(
|
|||||||
|
|
||||||
export function useQueryPodsMetrics(
|
export function useQueryPodsMetrics(
|
||||||
pods: Array<Instance | Endpoint | Service | any>,
|
pods: Array<Instance | Endpoint | Service | any>,
|
||||||
config: { metrics: string[]; metricTypes: string[] },
|
config: {
|
||||||
|
metrics: string[];
|
||||||
|
metricTypes: string[];
|
||||||
|
metricConfig: MetricConfigOpt[];
|
||||||
|
},
|
||||||
scope: string
|
scope: string
|
||||||
) {
|
) {
|
||||||
const metricTypes = (config.metricTypes || []).filter((m: string) => m);
|
const metricTypes = (config.metricTypes || []).filter((m: string) => m);
|
||||||
@ -287,12 +291,20 @@ export function useQueryPodsMetrics(
|
|||||||
};
|
};
|
||||||
const f = metrics.map((name: string, idx: number) => {
|
const f = metrics.map((name: string, idx: number) => {
|
||||||
const metricType = metricTypes[idx] || "";
|
const metricType = metricTypes[idx] || "";
|
||||||
|
variables.push(`$condition${index}${idx}: MetricsCondition!`);
|
||||||
conditions[`condition${index}${idx}`] = {
|
conditions[`condition${index}${idx}`] = {
|
||||||
name,
|
name,
|
||||||
entity: param,
|
entity: param,
|
||||||
};
|
};
|
||||||
variables.push(`$condition${index}${idx}: MetricsCondition!`);
|
let labelStr = "";
|
||||||
return `${name}${index}${idx}: ${metricType}(condition: $condition${index}${idx}, duration: $duration)${RespFields[metricType]}`;
|
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
||||||
|
variables.push(`$labels${index}${idx}: [String!]!`);
|
||||||
|
labelStr = `labels: $labels${index}${idx}, `;
|
||||||
|
conditions[`labels${index}${idx}`] = (
|
||||||
|
config.metricConfig[idx].label || ""
|
||||||
|
).split(",");
|
||||||
|
}
|
||||||
|
return `${name}${index}${idx}: ${metricType}(condition: $condition${index}${idx}, ${labelStr}duration: $duration)${RespFields[metricType]}`;
|
||||||
});
|
});
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@ -315,6 +327,7 @@ export function usePodsSource(
|
|||||||
ElMessage.error(resp.errors);
|
ElMessage.error(resp.errors);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
console.log(config);
|
||||||
const data = pods.map((d: Instance | any, idx: number) => {
|
const data = pods.map((d: Instance | any, idx: number) => {
|
||||||
config.metrics.map((name: string, index: number) => {
|
config.metrics.map((name: string, index: number) => {
|
||||||
const c: any = (config.metricConfig && config.metricConfig[index]) || {};
|
const c: any = (config.metricConfig && config.metricConfig[index]) || {};
|
||||||
@ -331,12 +344,31 @@ export function usePodsSource(
|
|||||||
Calculations.PercentageAvg,
|
Calculations.PercentageAvg,
|
||||||
].includes(c.calculation)
|
].includes(c.calculation)
|
||||||
) {
|
) {
|
||||||
|
if (Array.isArray(d[resp.data[key]])) {
|
||||||
|
for (const item of d[resp.data[key]]) {
|
||||||
|
d[item.label]["avg"] = calculateExp(
|
||||||
|
resp.data[key][item.label].values.values,
|
||||||
|
c
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
d[name]["avg"] = calculateExp(resp.data[key].values.values, c);
|
d[name]["avg"] = calculateExp(resp.data[key].values.values, c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (Array.isArray(d[resp.data[key]])) {
|
||||||
|
for (const item of d[resp.data[key]]) {
|
||||||
|
d[item.label]["values"] = resp.data[key][
|
||||||
|
item.label
|
||||||
|
].values.values.map((val: { value: number }) =>
|
||||||
|
aggregation(val.value, c)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
d[name]["values"] = resp.data[key].values.values.map(
|
d[name]["values"] = resp.data[key].values.values.map(
|
||||||
(val: { value: number }) => aggregation(val.value, c)
|
(val: { value: number }) => aggregation(val.value, c)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
@ -216,7 +216,7 @@ async function queryServiceMetrics(currentServices: Service[]) {
|
|||||||
const metricConfig = props.config.metricConfig || [];
|
const metricConfig = props.config.metricConfig || [];
|
||||||
services.value = usePodsSource(currentServices, json, {
|
services.value = usePodsSource(currentServices, json, {
|
||||||
...props.config,
|
...props.config,
|
||||||
metricConfig: metricConfig || [],
|
metricConfig,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user