This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-booster-ui.git
The following commit(s) were added to refs/heads/main by this push:
new 5e6e5aa7 Fix: correct the same labels for metrics (#467)
5e6e5aa7 is described below
commit 5e6e5aa737979bc82846b555f6ea2e57689af088
Author: Fine0830 <[email protected]>
AuthorDate: Thu Apr 24 11:58:29 2025 +0800
Fix: correct the same labels for metrics (#467)
---
src/hooks/useExpressionsProcessor.ts | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/hooks/useExpressionsProcessor.ts
b/src/hooks/useExpressionsProcessor.ts
index ecd74cfc..b4b54598 100644
--- a/src/hooks/useExpressionsProcessor.ts
+++ b/src/hooks/useExpressionsProcessor.ts
@@ -109,12 +109,12 @@ export async function
useDashboardQueryProcessor(configList: Indexable[]) {
return { source: {}, tips: [], typesOfMQE: [] };
}
const tips: string[] = [];
- const source: { [key: string]: unknown } = {};
+ const source: Indexable<unknown> = {};
const keys = Object.keys(resp.data);
const typesOfMQE: string[] = [];
for (let i = 0; i < config.metrics.length; i++) {
- const c: MetricConfigOpt = (config.metricConfig &&
config.metricConfig[i]) || {};
+ const metricConfig: MetricConfigOpt = (config.metricConfig &&
config.metricConfig[i]) || {};
const obj = resp.data[keys[i]] || {};
const results = obj.results || [];
const name = config.metrics[i];
@@ -125,15 +125,15 @@ export async function
useDashboardQueryProcessor(configList: Indexable[]) {
if (!obj.error) {
if ([ExpressionResultType.SINGLE_VALUE,
ExpressionResultType.TIME_SERIES_VALUES].includes(type)) {
for (const item of results) {
- const label =
+ let label =
item.metric &&
item.metric.labels.map((d: { key: string; value: string }) =>
`${d.key}=${d.value}`).join(",");
const values = item.values.map((d: { value: unknown }) => d.value)
|| [];
if (results.length === 1) {
- source[label || c.label || name] = values;
- } else {
- source[label] = values;
+ // If the metrics label does not exist, use the configuration
label or expression
+ label = label ? `${metricConfig.label || name}, ${label}` :
metricConfig.label || name;
}
+ source[label] = values;
}
}
if (([ExpressionResultType.RECORD_LIST,
ExpressionResultType.SORTED_LIST] as string[]).includes(type)) {
@@ -148,7 +148,7 @@ export async function
useDashboardQueryProcessor(configList: Indexable[]) {
const appStore = useAppStoreWithOut();
const variables: string[] = [`$duration: Duration!`];
let fragments = "";
- let conditions: Recordable = {
+ let conditions: Recordable<unknown> = {
duration: appStore.durationTime,
};
for (let i = 0; i < configArr.length; i++) {
@@ -465,7 +465,7 @@ export function
useQueryTopologyExpressionsProcessor(metrics: string[], instance
return { queryStr, conditions };
}
function handleExpressionValues(partMetrics: string[], resp: { [key:
string]: any }) {
- const obj: any = {};
+ const obj: Indexable = {};
for (let idx = 0; idx < instances.length; idx++) {
for (let index = 0; index < partMetrics.length; index++) {
const k = "expression" + idx + index;