From d646d5e28a46aacc4ff97044b38b3352885a7738 Mon Sep 17 00:00:00 2001 From: Yefu Zhang Date: Thu, 11 May 2023 18:47:05 +0800 Subject: [PATCH] [bugfix] topo panel, can't display metrics from self to self **Phenomenon and reproduction steps** none **Root cause and solution** none **Impactions** none **Test method** none **Affected branch(es)** - main **Checklist** - [ ] Dependencies update required - [ ] Common bug (similar problem in other repo) --- deepflow-topo-panel/src/SimplePanel.tsx | 9 +++++++-- deepflow-topo-panel/src/utils/tools.ts | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/deepflow-topo-panel/src/SimplePanel.tsx b/deepflow-topo-panel/src/SimplePanel.tsx index 945e0a7..6636e33 100644 --- a/deepflow-topo-panel/src/SimplePanel.tsx +++ b/deepflow-topo-panel/src/SimplePanel.tsx @@ -197,8 +197,13 @@ export const SimplePanel: React.FC = ({ id, options, data, width, height if (_commonTags.length !== queryConfig.common?.length) { const fullDataAfterGroupBy = _.groupBy(fullData, item => { return [...sourceSide, ...destinationSide, ..._commonTags] - .map((key: string) => { - return genUniqueFieldByTag(key, item) + .map((tagName: string) => { + // must use type and id to unique a auto group by tag + if (/resource_gl|auto_instance|auto_service/.test(tagName)) { + const nodeTypeId = item[tagName.replace('_id', '_type')] + return [genUniqueFieldByTag(tagName, item), nodeTypeId].join(',') + } + return genUniqueFieldByTag(tagName, item) }) .join(',') }) diff --git a/deepflow-topo-panel/src/utils/tools.ts b/deepflow-topo-panel/src/utils/tools.ts index 78fff4e..53aad4e 100644 --- a/deepflow-topo-panel/src/utils/tools.ts +++ b/deepflow-topo-panel/src/utils/tools.ts @@ -135,13 +135,11 @@ export function formatUsUnit(num: any, unit = 1000, digits = 2, lang = 'en') { // ip: 255, internet_ip: 0 const IP_LIKELY_NODE_TYPE_IDS = [255, 0] export function genUniqueFieldByTag(tagName: string, item: any): string { - // must use type and id to unique a auto group by tag if (/resource_gl|auto_instance|auto_service/.test(tagName)) { const nodeTypeId = item[tagName.replace('_id', '_type')] if (IP_LIKELY_NODE_TYPE_IDS.includes(Number(nodeTypeId))) { - return [nodeTypeId, item[tagName], item[tagName.replace('_id', '')]].join(',') + return `${item[tagName.replace('_id', '')]},${item[tagName]}` } - return [nodeTypeId, item[tagName]].join(',') } return item[tagName] }