Skip to content

Commit

Permalink
feat: add memory usage utilization panel (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
xigongdaEricyang authored Apr 14, 2023
1 parent 9e25143 commit 2c24526
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config/locale/en-US/device.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"openfiledesc": "Open File Desc & Context Switch",
"diskIONum": "Disk IO Capacity",
"memory": "Memory",
"memoryPercentage": "Memory Utilization",
"load": "Load",
"network": "Network",
"networkIn": "Network In",
Expand Down
4 changes: 4 additions & 0 deletions src/config/locale/en-US/metric_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
"memory_avaliable": "avaliable",
"memory_cached": "cache + buffer",
"memory_swap_used": "SWAP used",
"memory_currnet_used_utilization": "used",
"memory_avaliable_utilization": "available",
"memory_cached_utilization": "cache + buffer",
"memory_swap_utilization": "SWAP",
"cpu_load_1": "load 1min",
"cpu_load_5": "load 5min",
"cpu_load_15": "load 15min",
Expand Down
1 change: 1 addition & 0 deletions src/config/locale/zh-CN/device.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cpu": "CPU",
"disk": "磁盘",
"memory": "内存",
"memoryPercentage": "内存使用率",
"diskIO": "磁盘读写速率(IOPS)",
"openfiledesc": "打开文件描述符&上下文切换",
"diskIONum": "磁盘读写容量",
Expand Down
4 changes: 4 additions & 0 deletions src/config/locale/zh-CN/metric_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
"memory_avaliable": "可用",
"memory_cached": "缓存",
"memory_swap_used": "SWAP 用量",
"memory_currnet_used_utilization": "已使用率",
"memory_avaliable_utilization": "可用率",
"memory_cached_utilization": "缓存使用率",
"memory_swap_utilization": "SWAP 使用率",
"cpu_load_1": "1分钟负载",
"cpu_load_5": "5分钟负载",
"cpu_load_15": "15分钟负载",
Expand Down
23 changes: 23 additions & 0 deletions src/utils/promQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,29 @@ export const getMachineMetricData = (instance, cluster) => {
}
]
},
memory_utilization: {
title: intl.get('device.memoryPercentage'),
valueType: VALUE_TYPE.percentage,
viewPath: `/machine-metric/memory_utilization/${encodedInstance}`,
queries: [
{
refId: 'memory_currnet_used_utilization',
query: `(node_memory_MemTotal_bytes{${instanceSuffix}${clusterSuffix1}} - node_memory_MemAvailable_bytes{${instanceSuffix}${clusterSuffix1}}) / (node_memory_MemTotal_bytes{${instanceSuffix}${clusterSuffix1}}) * 100`,
},
{
refId: 'memory_avaliable_utilization',
query: `node_memory_MemAvailable_bytes{${instanceSuffix}${clusterSuffix1}} / (node_memory_MemTotal_bytes{${instanceSuffix}${clusterSuffix1}}) * 100`,
},
{
refId: 'memory_cached_utilization',
query: `(node_memory_Buffers_bytes{${instanceSuffix}${clusterSuffix1}} + node_memory_Cached_bytes{${instanceSuffix}${clusterSuffix1}}) / (node_memory_MemTotal_bytes{${instanceSuffix}${clusterSuffix1}}) * 100`,
},
{
refId: 'memory_swap_utilization',
query: `(node_memory_SwapTotal_bytes{${instanceSuffix}${clusterSuffix1}} - node_memory_SwapFree_bytes{${instanceSuffix}${clusterSuffix1}}) / (node_memory_MemTotal_bytes{${instanceSuffix}${clusterSuffix1}}) * 100`,
},
]
},
memory: {
title: intl.get('device.memory'),
valueType: VALUE_TYPE.byte,
Expand Down

0 comments on commit 2c24526

Please sign in to comment.