Skip to content

Commit

Permalink
[bugfix] topo panel, can't display metrics from self to self
Browse files Browse the repository at this point in the history
**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)
  • Loading branch information
twou12031 authored and Nick-0314 committed May 17, 2023
1 parent e040d50 commit d646d5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 7 additions & 2 deletions deepflow-topo-panel/src/SimplePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ export const SimplePanel: React.FC<Props> = ({ 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(',')
})
Expand Down
4 changes: 1 addition & 3 deletions deepflow-topo-panel/src/utils/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down

0 comments on commit d646d5e

Please sign in to comment.