From 2f1930b69e28a59ae66ebdfa9bdabd29483bd931 Mon Sep 17 00:00:00 2001 From: Rivery <9858560+xigongdaEricyang@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:32:09 +0800 Subject: [PATCH] feat: add customize panel in machine panel overview (#245) --- src/components/MetricCard/index.tsx | 2 +- .../locale/en-US/metric_description.json | 116 +++++++------ .../locale/zh-CN/metric_description.json | 114 +++++++------ .../MachinePanelDetail/index.module.less | 47 ------ .../MachinePanelDetail/index.tsx | 154 ------------------ .../defaultMachinePanelConfig.ts | 87 ++++++++++ src/pages/MachineDashboard/index.tsx | 87 +++++++--- .../ServiceDashboard/defaultPanelConfig.ts | 23 +++ src/utils/interface.ts | 8 + src/utils/promQL.ts | 147 +++++++++-------- 10 files changed, 392 insertions(+), 393 deletions(-) delete mode 100644 src/pages/MachineDashboard/MachinePanelDetail/index.module.less delete mode 100644 src/pages/MachineDashboard/MachinePanelDetail/index.tsx create mode 100644 src/pages/MachineDashboard/defaultMachinePanelConfig.ts diff --git a/src/components/MetricCard/index.tsx b/src/components/MetricCard/index.tsx index ee83f417..f8c3c3bc 100644 --- a/src/components/MetricCard/index.tsx +++ b/src/components/MetricCard/index.tsx @@ -39,7 +39,7 @@ const MetricCard = forwardRef((props: IProps, ref) => { ), [queries, chartRef.current]); const defaultMetricTypeFn = (resultNum: number, refId: string, resultMetric: PromResultMetric) => { - return resultNum > 1 ? resultMetric.device + intl.get(`metric_description.${refId}`) : intl.get(`metric_description.${refId}`); + return resultNum > 1 ? resultMetric.device + intl.get(`metric_description.overview_label.${refId}`) : intl.get(`metric_description.overview_label.${refId}`); } const asyncGetMetricData = async (queries) => { diff --git a/src/config/locale/en-US/metric_description.json b/src/config/locale/en-US/metric_description.json index 840faafd..6d33cb9a 100644 --- a/src/config/locale/en-US/metric_description.json +++ b/src/config/locale/en-US/metric_description.json @@ -1,23 +1,23 @@ { "cpu_utilization": "The percentage of used CPU", "cpu_idle": "The percentage of idled CPU", - "cpu_wait": "The percentage of CPU waiting for IO operations", - "cpu_user": "The percentage of CPU used by users", - "cpu_system": "The percentage of CPU used by the system", - "memory_utilization": "The percentage of used memory", - "memory_used": "The memory space used (including cache and buffer)", - "memory_used_percentage": "The percentage of used memory(including cache and buffer)", - "memory_actual_used": "The memory space used (not including cache and buffer)", - "memory_actual_used_percentage": "The percentage of used memory (not including cache and buffer)", - "memory_free": "The memory space available", + "cpu_io_wait_used": "The percentage of CPU waiting for IO operations", + "cpu_user_used": "The percentage of CPU used by users", + "cpu_system_used": "The percentage of CPU used by the system", + "memory_used_utilization": "The percentage of used memory", + "memory_avaliable_utilization": "The percentage of avaliable memory", + "memory_swap_utilization": "The percentage of used swap", + "memory_cached_utilization": "The percentage of used cached", + "memory_total": "The total memory", + "memory_used": "The memory space used", + "memory_avaliable": "The memory space available", "memory_swap_total": "The total memory space of the swap", - "memory_cached_buffer_used": "The memory space used by cache and buffer", - "memory_cached_buffer_used_percentage": "The percentage of used memory by cache and buffer", + "memory_swap_used": "The swap used", + "memory_cached": "The memory space used by cache and buffer", "root_fs_used_percentage": "The percentage of used disk space of the root file system", - "load_1m": "The average load of the system in the last 1 minute", - "load_5m": "The average load of the system in the last 5 minutes", - "load_15s": "The average load of the system in the last 15 seconds", - "load_15m": "The average load of the system in the last 15 minutes", + "load_1": "The average load of the system in the last 1 minute", + "load_5": "The average load of the system in the last 5 minutes", + "load_15": "The average load of the system in the last 15 minutes", "disk_used": "The disk space used", "disk_free": "The disk space available", "disk_readbytes": "The number of bytes that the system reads in the disk per second", @@ -142,38 +142,56 @@ "appendLogs_latency_us": "The latency of appending logs.", "more": "More", "enable_space_level_metrics_tip": "To enable space-level metrics, please set the value of enable_space_level_metrics to true in the Graph service configuration", - "cpu_total_used": "total used", - "cpu_system_used": "system used", - "cpu_user_used": "user used", - "cpu_io_wait_used": "io wait used", - "memory_total": "total", - "memory_currnet_used": "used", - "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", - "disk_read_rate": "read", - "disk_write_rate": "write", - "open_file_desc": "open file desc", - "context_switch_rate": "conetxt switch", - "graphd_latency": "Graphd Latency", - "graphd_queries": "Graphd Query", - "graphd_sessions": "Graphd Session", - "process_memory": "Process Memory Usage", - "process_resource": "Process Disk Read/Write Bytes", - "process_cpu": "Process Cpu Usage", - "process_context_switch": "Process Context Switch & open file desc", - "metad_latency": "Metad Latency", - "metad_nums": "Metad Num Related", - "storage_latency": "Storage Latency", - "storaged_edge_nums": "Edge Num Related", - "storaged_vertices_nums": "Vertices Num Related", - "storaged_tag_and_dst_nums": "Tag and Src&Dst Num Related", - "storaged_other_nums": "Other Num Related" + "overview_label": { + "cpu_system_used": "cpu system used", + "cpu_utilization": "cpu total used", + "cpu_user_used": "cpu user used", + "cpu_io_wait_used": "cpu io wait used", + "cpu_idle": "cpu idle", + "memory_total": "memory total", + "memory_used": "memory used", + "memory_avaliable": "memory avaliable", + "memory_cached": "memory cache + buffer", + "memory_swap_total": "SWAP total", + "memory_swap_used": "SWAP used", + "memory_used_utilization": "memory used", + "memory_avaliable_utilization": "memory available", + "memory_cached_utilization": "memory cache + buffer", + "memory_swap_utilization": "SWAP", + "load_1": "load 1min", + "load_5": "load 5min", + "load_15": "load 15min", + "disk_used": "disk used", + "disk_free": "disk free", + "disk_readbytes": "disk read", + "disk_writebytes": "disk write", + "inode_utilization": "innode used", + "open_file_desc": "open file desc", + "disk_readiops": "disk read", + "disk_writeiops": "disk write", + "disk_used_percentage": "disk used", + "disk_size": "disk size", + "root_fs_used_percentage": "root fs used", + "network_in_rate": "network in", + "network_out_rate": "network out", + "network_in_errs": "netowrk in errors", + "network_out_errs": "netowrk out errors", + "network_in_packets": "netowrk in packets", + "network_out_packets": "netowrk out packets", + "context_switch_rate": "context switch", + "graphd_latency": "Graphd Latency", + "graphd_queries": "Graphd Query", + "graphd_sessions": "Graphd Session", + "process_memory": "Process Memory Usage", + "process_resource": "Process Disk Read/Write Bytes", + "process_cpu": "Process Cpu Usage", + "process_context_switch": "Process Context Switch & open file desc", + "metad_latency": "Metad Latency", + "metad_nums": "Metad Num Related", + "storage_latency": "Storage Latency", + "storaged_edge_nums": "Edge Num Related", + "storaged_vertices_nums": "Vertices Num Related", + "storaged_tag_and_dst_nums": "Tag and Src&Dst Num Related", + "storaged_other_nums": "Other Num Related" + } } \ No newline at end of file diff --git a/src/config/locale/zh-CN/metric_description.json b/src/config/locale/zh-CN/metric_description.json index 8c6eb474..8ea20e4d 100644 --- a/src/config/locale/zh-CN/metric_description.json +++ b/src/config/locale/zh-CN/metric_description.json @@ -1,22 +1,26 @@ { "cpu_utilization": "CPU已使用百分比", "cpu_idle": "CPU总空闲百分比", - "cpu_wait": "等待IO操作使用的CPU百分比", - "cpu_user": "用户空间占用的CPU百分比", - "cpu_system": "系统空间占用的CPU百分比", - "memory_used": "已使用内存(包括Buffer缓存和Cached缓存)", - "memory_used_percentage": "已使用内存百分比(包括Buffer缓存和Cached缓存)", - "memory_actual_used": "实际使用内存(不包括Buffer缓存和Cached缓存)", - "memory_actual_used_percentage": "实际使用内存百分比(不包括Buffer缓存和Cached缓存)", + "cpu_io_wait_used": "等待IO操作使用的CPU百分比", + "cpu_user_used": "用户空间占用的CPU百分比", + "cpu_system_used": "系统空间占用的CPU百分比", + "memory_used": "已使用内存", + "memory_used_utilization": "已使用内存百分比", + "memory_avaliable_utilization": "可用内存百分比", + "memory_cached_utilization": "已使用的Cached缓存百分比", + "memory_swap_utilization": "已使用的SWAP交换分区百分比", "memory_free": "空闲内存", "memory_swap_total": "SWAP 交换分区的大小", "root_fs_used_percentage": "根文件系统磁盘使用率", "memory_cached_buffer_used": "已使用的Buffer缓存和Cached缓存大小", "memory_cached_buffer_used_percentage": "已使用的Buffer缓存和Cached缓存百分比", - "load_1m": "最近1分钟系统平均负载", - "load_5m": "最近5分钟系统平均负载", - "load_15s": "最近15秒系统平均负载", - "load_15m": "最近15分钟系统平均负载", + "memory_total": "总内存", + "memory_avaliable": "可用内存", + "memory_cached": "已使用的Cached缓存大小", + "memory_swap_used": "已使用的SWAP交换分区大小", + "load_1": "最近1分钟系统平均负载", + "load_5": "最近5分钟系统平均负载", + "load_15": "最近15分钟系统平均负载", "disk_used": "磁盘已使用存储空间", "disk_free": "磁盘剩余存储空间", "disk_readbytes": "磁盘每秒读取的字节数", @@ -141,40 +145,56 @@ "appendLogs_latency_us": "写日志的延迟时间。", "more": "更多参数说明", "enable_space_level_metrics_tip": "如需开启图空间监控指标,请先在 Graph 服务的配置文件中将enable_space_level_metrics参数的值修改为true", - "cpu_total_used": "总使用率", - "cpu_system_used": "系统使用率", - "cpu_user_used": "用户使用率", - "cpu_io_wait_used": "磁盘IO使用率", - "memory_total": "总内存", - "memory_currnet_used": "已使用", - "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分钟负载", - "disk_read_rate": "读取", - "disk_write_rate": "写入", - "network_in": "上行流量速率", - "network_out": "下行流量速率", - "open_file_desc": "打开文件描述符", - "context_switch_rate": "每秒上下文切换次数", - "graphd_latency": "Graphd 延迟", - "graphd_queries": "Graphd 查询", - "graphd_sessions": "Graphd Session", - "process_memory": "进程内存使用", - "process_disk": "进程磁盘读写", - "process_cpu": "进程CPU使用率", - "process_context_open_file_desc": "进程上下文切换 & 文件句柄", - "metad_latency": "Metad 延迟", - "metad_nums": "Metad 数值相关", - "storage_latency": "Storage 延迟", - "storaged_edge_nums": "边数据相关", - "storaged_vertices_nums": "点数据相关", - "storaged_tag_and_dst_nums": "tag与路径相关", - "storaged_other_nums": "其他数值指标" + "overview_label": { + "cpu_utilization": "cpu 总使用率", + "cpu_system_used": "cpu 系统使用率", + "cpu_user_used": "cpu 用户使用率", + "cpu_io_wait_used": "cpu 磁盘IO使用率", + "cpu_idle": "cpu 空闲率", + "memory_total": "总内存", + "memory_used": "已使用内存", + "memory_avaliable": "可用内存", + "memory_cached": "缓存", + "memory_swap_used": "SWAP 用量", + "memory_swap_total":"SWAP 总量", + "memory_used_utilization": "内存已使用率", + "memory_avaliable_utilization": "内存可用率", + "memory_cached_utilization": "缓存使用率", + "memory_swap_utilization": "SWAP 使用率", + "load_1": "1分钟负载", + "load_5": "5分钟负载", + "load_15": "15分钟负载", + "disk_used": "磁盘已使用", + "disk_free": "磁盘剩余", + "disk_readbytes": "磁盘读取", + "disk_writebytes": "磁盘写入", + "inode_utilization": "innode 使用率", + "disk_readiops": "磁盘读取", + "disk_writeiops": "磁盘写入", + "disk_size": "磁盘大小", + "root_fs_used_percentage": "根文件系统磁盘使用率", + "disk_used_percentage": "磁盘使用率", + "network_in_rate": "上行流量速率", + "network_out_rate": "下行流量速率", + "network_in_errs": "上行流量报错", + "network_out_errs": "下行流量报错", + "network_in_packets": "上行流量数据包", + "network_out_packets": "下行流量数据包", + "open_file_desc": "打开文件描述符", + "context_switch_rate": "每秒上下文切换次数", + "graphd_latency": "Graphd 延迟", + "graphd_queries": "Graphd 查询", + "graphd_sessions": "Graphd Session", + "process_memory": "进程内存使用", + "process_disk": "进程磁盘读写", + "process_cpu": "进程CPU使用率", + "process_context_open_file_desc": "进程上下文切换 & 文件句柄", + "metad_latency": "Metad 延迟", + "metad_nums": "Metad 数值相关", + "storage_latency": "Storage 延迟", + "storaged_edge_nums": "边数据相关", + "storaged_vertices_nums": "点数据相关", + "storaged_tag_and_dst_nums": "tag与路径相关", + "storaged_other_nums": "其他数值指标" + } } \ No newline at end of file diff --git a/src/pages/MachineDashboard/MachinePanelDetail/index.module.less b/src/pages/MachineDashboard/MachinePanelDetail/index.module.less deleted file mode 100644 index b1dab9e0..00000000 --- a/src/pages/MachineDashboard/MachinePanelDetail/index.module.less +++ /dev/null @@ -1,47 +0,0 @@ -.dashboard-detail { - height: 100%; -} - -.common-header { - background: #fff; - padding: 15px; - justify-content: flex-start; - height: auto; - display: flex; - align-items: center; -} - -.detail-content { - margin-top: 24px; - flex: 1; - display: flex; - flex-direction: row; - flex-wrap: wrap; - width: 100%; - :global { - .dashboard-card { - height: calc(100vh - 290px); - width: 100%; - margin-bottom: 24px; - border-radius: 3px; - position: relative; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - background: #fff; - padding: 16px; - margin-right: 15px; - position: sticky; - top: -15px; - z-index: 10; - box-shadow: 0 2px 8px #f0f1f2; - .inner{ - width: 100%; - } - .nebula-chart-line { - height: 100%; - } - } - } -} \ No newline at end of file diff --git a/src/pages/MachineDashboard/MachinePanelDetail/index.tsx b/src/pages/MachineDashboard/MachinePanelDetail/index.tsx deleted file mode 100644 index 3062fc52..00000000 --- a/src/pages/MachineDashboard/MachinePanelDetail/index.tsx +++ /dev/null @@ -1,154 +0,0 @@ -import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { Spin } from 'antd'; -import { connect } from 'react-redux'; -import { useParams } from 'react-router-dom'; -import intl from 'react-intl-universal'; - -import DashboardCard from '@/components/DashboardCard'; -import MetricCard from '@/components/MetricCard'; -import TimeSelect from '@/components/TimeSelect'; - -import styles from './index.module.less'; -import FrequencySelect from '@/components/MetricsFilterPanel/FrequencySelect'; -import { getMachineMetricData } from '@/utils/promQL'; -import { TIME_OPTION_TYPE } from '@/utils/dashboard'; -import DiskCard from '../Cards/DiskCard'; - -const mapState = (state: any) => ({ - cluster: state.cluster.cluster, -}); - -interface IProps extends ReturnType { - -} - -function MachinePanelDetail(props: IProps) { - const { cluster } = props; - const [loading, setLoading] = useState(false); - const { instance, panelKey } = useParams<{ - instance: string; - panelKey: string; - }>(); - const [panelInfo, setPanelInfo] = useState(); - - const [timeRange, setTimeRange] = useState< - TIME_OPTION_TYPE | [number, number] - >(TIME_OPTION_TYPE.HOUR1); - - const curInstance = useMemo(() => instance.replaceAll('_', '.'), [instance]); - - const cardObj = useMemo(() => getMachineMetricData(curInstance, cluster), [curInstance, cluster]); - const diskCardRef = useRef(); - const metricRef = useRef(); - const [frequencyValue, setFrequencyValue] = useState(0); - const pollingTimerRef = useRef(null); - - useEffect(() => { - if (panelKey) { - setPanelInfo(cardObj[panelKey]) - } - }, [panelKey, cardObj]) - - useEffect(() => { - if (pollingTimerRef.current) { - clearPolling(); - } - if (frequencyValue > 0) { - pollingData(); - } - }, [frequencyValue]); - - const clearPolling = () => { - if (pollingTimerRef.current) { - clearInterval(pollingTimerRef.current); - } - }; - - const handleTimeSelectChange = ( - value: TIME_OPTION_TYPE | [number, number], - ) => { - setTimeRange(value); - }; - - const pollingData = () => { - fetchMonitorData(false); - if (frequencyValue > 0) { - pollingTimerRef.current = setInterval(() => { - fetchMonitorData(false); - }, frequencyValue); - } - }; - - useEffect(() => { - fetchMonitorData(true); - }, [panelInfo, timeRange]); - - const fetchMonitorData = (shouldLoading: boolean) => { - shouldLoading && setLoading(true); - if (panelKey === 'disk') { - diskCardRef.current?.handleRefresh?.().then(() => { - shouldLoading && setLoading(false); - }); - } else { - metricRef.current?.handleRefresh?.().then(() => { - shouldLoading && setLoading(false); - }); - } - }; - - const renderDetailContent = () => { - if (panelKey === 'disk') { - return ( - - - - ); - } - if (panelInfo) { - return ( - - - - ) - } - } - - const handleFrequencyChange = (value: number) => { - setFrequencyValue(value); - }; - - const handleRefresh = () => { - fetchMonitorData(true); - }; - - return ( - -
- { - panelKey != 'disk' && ( -
- -
- -
-
- ) - } -
- {renderDetailContent()} -
-
-
- ) -} - -export default connect(mapState)(MachinePanelDetail); \ No newline at end of file diff --git a/src/pages/MachineDashboard/defaultMachinePanelConfig.ts b/src/pages/MachineDashboard/defaultMachinePanelConfig.ts new file mode 100644 index 00000000..3f9d7bf3 --- /dev/null +++ b/src/pages/MachineDashboard/defaultMachinePanelConfig.ts @@ -0,0 +1,87 @@ +import { MachinePanelConfig } from '@/utils/interface'; +import { VALUE_TYPE } from '@/utils/promQL'; +import intl from 'react-intl-universal'; + +export default [ + { + title: intl.get('device.cpu'), + valueType: VALUE_TYPE.percentage, + key: 'default_cpu', + refIds: [ + 'cpu_utilization', + 'cpu_system_used', + 'cpu_user_used', + 'cpu_io_wait_used', + ] + }, + { + title: intl.get('device.memoryPercentage'), + valueType: VALUE_TYPE.percentage, + key: 'default_meory_utilization', + refIds: [ + 'memory_used_utilization', + 'memory_avaliable_utilization', + 'memory_cached_utilization', + 'memory_swap_utilization', + ] + }, + { + title: intl.get('device.memory'), + valueType: VALUE_TYPE.byte, + key: 'default_memory', + refIds: [ + 'memory_total', + 'memory_used', + 'memory_avaliable', + 'memory_cached', + 'memory_swap_used', + 'memory_swap_total', + ] + }, + { + title: intl.get('device.diskIO'), + valueType: VALUE_TYPE.diskIONet, + key: 'default_diskio', + refIds: [ + 'disk_readiops', + 'disk_writeiops' + ] + }, + { + title: intl.get('device.diskIONum'), + valueType: VALUE_TYPE.byteSecondNet, + key: 'default_diskionum', + refIds: [ + 'disk_readbytes', + 'disk_writebytes', + ] + }, + { + title: intl.get('device.network'), + valueType: VALUE_TYPE.byteSecondNet, + key: 'default_network', + refIds: [ + 'network_in_rate', + 'network_out_rate' + ] + }, + { + title: intl.get('device.load'), + valueType: VALUE_TYPE.number, + key: 'default_load', + refIds: [ + 'load_1', + 'load_5', + 'load_15' + ] + }, + { + title: intl.get('device.openfiledesc'), + valueType: VALUE_TYPE.number, + key: 'default_openfile', + refIds: [ + 'open_file_desc', + 'context_switch_rate', + ] + } +] as MachinePanelConfig[] \ No newline at end of file diff --git a/src/pages/MachineDashboard/index.tsx b/src/pages/MachineDashboard/index.tsx index c83668fb..a4026071 100644 --- a/src/pages/MachineDashboard/index.tsx +++ b/src/pages/MachineDashboard/index.tsx @@ -1,11 +1,11 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; import { connect } from 'react-redux'; import intl from 'react-intl-universal'; -import { Col, Row, Spin } from 'antd'; +import { Button, Col, Row, Spin } from 'antd'; -import { NodeResourceInfo } from '@/utils/interface'; +import { MachinePanelConfig, NodeResourceInfo } from '@/utils/interface'; import NodeResourceOverview from './NodeResourceOverview'; -import { getMachineMetricData, getNodeInfoQueries } from '@/utils/promQL'; +import { getNodeInfoQueries } from '@/utils/promQL'; import { getMachineRouterPath, getProperByteDesc, TIME_OPTION_TYPE } from '@/utils/dashboard'; import EventBus from '@/utils/EventBus'; import { DashboardSelect, Option } from '@/components/DashboardSelect'; @@ -15,19 +15,26 @@ import MetricCard from '@/components/MetricCard'; import DiskCard from './Cards/DiskCard'; import WaterLevelCard from './Cards/WaterLevelCard'; import { asyncBatchQueries } from '@/requests'; +import { LINUX as PROMQL } from '@/utils/promQL'; import styles from './index.module.less'; +import Icon from '@/components/Icon'; +import defaultMachinePanelConfig from './defaultMachinePanelConfig'; const mapDispatch: any = (_dispatch: any) => ({ }); const mapState = (state: any) => ({ instanceList: state.machine.instanceList as any, + cluster: state.cluster.cluster, }); interface IProps extends ReturnType, ReturnType { - cluster?: any; + enableAddPanel?: boolean; + onAddPanel?: () => void; + onEditPanel?: (panelItem: MachinePanelConfig) => void; + panelConfigs?: MachinePanelConfig[]; } const formatValueByRefId = (refId: string, metricItem: any) => { @@ -56,7 +63,7 @@ const formatValueByRefId = (refId: string, metricItem: any) => { function MachineDashboard(props: IProps) { - const { cluster, instanceList } = props; + const { cluster, instanceList, enableAddPanel, onAddPanel, onEditPanel, panelConfigs = defaultMachinePanelConfig } = props; const [resourceInfos, setResourceInfos] = useState([]); @@ -72,7 +79,6 @@ function MachineDashboard(props: IProps) { const diskCardRef = useRef(); const metricRefs = useMemo(() => ({}), []); const pollingTimerRef = useRef(null); - const cardObj = useMemo(() => getMachineMetricData(curInstance, cluster), [curInstance, cluster]); useEffect(() => { if (cluster?.id && instanceList?.length) { @@ -127,10 +133,10 @@ function MachineDashboard(props: IProps) { } useEffect(() => { - if (cluster?.id && curInstance) { + if (panelConfigs.length) { fetchSingleMonitorData(true); } - }, [curInstance, cluster, timeRange]) + }, [timeRange, panelConfigs]) const handleRefresh = () => { asyncGetResourceInfos(true); @@ -138,14 +144,14 @@ function MachineDashboard(props: IProps) { } const fetchSingleMonitorData = (shouldLoading?: boolean) => { + if (!cluster?.id || !curInstance) return; shouldLoading && setSingleNodeLoading(true); diskCardRef.current?.handleRefresh?.(); - Promise.all( - Object.keys(cardObj) - .map(key => metricRefs[key]?.handleRefresh?.())) - .then(() => { - shouldLoading && setSingleNodeLoading(false); - }) + const promsises = panelConfigs.map(panelConfigItem => metricRefs[panelConfigItem.key]?.handleRefresh?.()) + + Promise.all(promsises).then(() => { + shouldLoading && setSingleNodeLoading(false); + }) } const clearPolling = () => { @@ -179,27 +185,46 @@ function MachineDashboard(props: IProps) { const handleTimeSelectChange = (value: TIME_OPTION_TYPE | [number, number]) => { setTimeRange(value); } - const onChangeBrush = (metric: string, brush) => { + + const onChangeBrush = (panelKey: string, brush) => { Object.keys(metricRefs).forEach(key => { - if (key !== metric || !brush) { + if (key !== panelKey || !brush) { metricRefs[key].chartRef.changeBrushByRangeFilter(brush); } }); } + + const getMachineQueries = (refIds: string[]) => { + if (!cluster?.id) return []; + return refIds.map(refId => ({ + refId, + query: PROMQL(cluster.id, '', curInstance)[refId] + })); + } + + const sortedPanels = (panels: MachinePanelConfig[]) => { + return panels.sort((panelA, panelB) => { + const AIndex = panelA.showIndex ? +panelA.showIndex : Number.MAX_VALUE; + const BIndex = panelB.showIndex ? +panelB.showIndex : Number.MAX_VALUE; + return AIndex - BIndex; + }); + } + const renderCardContent = () => { - return Object.keys(cardObj).map(key => ( + return sortedPanels(panelConfigs).map((panelConfigItem: MachinePanelConfig, index) => ( onEditPanel(panelConfigItem): undefined} + viewPath={getViewPath(`/machine-metric/${panelConfigItem.key}/${curInstance.replaceAll('.', '_')}`)} > metricRefs[key] = ref} + ref={ref => metricRefs[panelConfigItem.key] = ref} onChangeBrush={(brush) => { - onChangeBrush(key,brush); + onChangeBrush(panelConfigItem.key, brush); }} - queries={cardObj[key].queries} - valueType={cardObj[key].valueType} + queries={getMachineQueries(panelConfigItem.refIds)} + valueType={panelConfigItem.valueType} timeRange={timeRange} /> @@ -231,6 +256,18 @@ function MachineDashboard(props: IProps) {
+ { + enableAddPanel && ( + + ) + }
@@ -247,7 +284,7 @@ function MachineDashboard(props: IProps) { title={intl.get('device.disk')} viewPath={getViewPath(`/machine-metric/disk/${curInstance}`)} > - + diff --git a/src/pages/ServiceDashboard/defaultPanelConfig.ts b/src/pages/ServiceDashboard/defaultPanelConfig.ts index 130ffc16..4eb7dc53 100644 --- a/src/pages/ServiceDashboard/defaultPanelConfig.ts +++ b/src/pages/ServiceDashboard/defaultPanelConfig.ts @@ -3,6 +3,7 @@ import { VALUE_TYPE } from "@/utils/promQL"; import { BatchQueryItem, ServiceName } from '@/utils/interface'; export interface ServicePanelConfig { + key: string; title: string; valueType: VALUE_TYPE; space?: string; @@ -23,6 +24,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ title: intl.get('metric_description.graphd_latency'), valueType: VALUE_TYPE.latency, space: '', + key: 'graphd_latency', queries: [ { refId: 'slow_query_latency', @@ -42,6 +44,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ title: intl.get('metric_description.graphd_sessions'), valueType: VALUE_TYPE.number, space: '', + key: 'graphd_sessions', queries: [ { refId: 'active_sessions', @@ -69,6 +72,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ title: intl.get('metric_description.graphd_queries'), valueType: VALUE_TYPE.number, space: '', + key: 'graphd_queries', queries: [ { refId: 'active_queries', @@ -99,6 +103,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_disk'), valueType: VALUE_TYPE.byte, + key: 'process_disk', space: '', queries: [ { @@ -114,6 +119,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_cpu'), valueType: VALUE_TYPE.percentage, + key: 'process_cpu', queries: [ { refId: 'cpu_seconds_total', @@ -124,6 +130,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_memory'), valueType: VALUE_TYPE.byte, + key: 'process_memory', queries: [ { refId: 'memory_bytes_gauge', @@ -134,6 +141,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_context_open_file_desc'), valueType: VALUE_TYPE.number, + key: 'process_context_open_file_desc', queries: [ { refId: 'context_switches_total', @@ -153,6 +161,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.metad_latency'), valueType: VALUE_TYPE.latency, + key: 'metad_latency', queries: [ { refId: 'append_log_latency', @@ -187,6 +196,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.metad_nums'), valueType: VALUE_TYPE.number, + key: 'metad_nums', queries: [ { refId: 'num_grant_votes', @@ -209,6 +219,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_disk'), valueType: VALUE_TYPE.byte, + key: 'process_disk', queries: [ { refId: 'read_bytes_total', @@ -223,6 +234,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_cpu'), valueType: VALUE_TYPE.percentage, + key: 'process_cpu', queries: [ { refId: 'cpu_seconds_total', @@ -233,6 +245,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_memory'), valueType: VALUE_TYPE.byte, + key: 'process_memory', queries: [ { refId: 'memory_bytes_gauge', @@ -243,6 +256,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_context_open_file_desc'), valueType: VALUE_TYPE.number, + key: 'process_context_open_file_desc', queries: [ { refId: 'context_switches_total', @@ -262,6 +276,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.storage_latency'), valueType: VALUE_TYPE.latency, + key: 'storage_latency', queries: [ { refId: 'add_edges_latency', @@ -312,6 +327,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.storaged_edge_nums'), valueType: VALUE_TYPE.number, + key: 'storaged_edge_nums', queries: [ { refId: 'num_edges_deleted', @@ -326,6 +342,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.storaged_vertices_nums'), valueType: VALUE_TYPE.number, + key: 'storaged_vertices_nums', queries: [ { refId: 'num_vertices_deleted', @@ -340,6 +357,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.storaged_tag_and_dst_nums'), valueType: VALUE_TYPE.number, + key: 'storaged_tag_and_dst_nums', queries: [ { refId: 'num_tags_deleted', @@ -362,6 +380,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.storaged_other_nums'), valueType: VALUE_TYPE.number, + key: 'storaged_other_nums', queries: [ { refId: 'num_grant_votes', @@ -396,6 +415,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_disk'), valueType: VALUE_TYPE.byte, + key: 'process_disk', queries: [ { refId: 'read_bytes_total', @@ -410,6 +430,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_cpu'), valueType: VALUE_TYPE.percentage, + key: 'process_cpu', queries: [ { refId: 'cpu_seconds_total', @@ -420,6 +441,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_memory'), valueType: VALUE_TYPE.byte, + key: 'process_memory', queries: [ { refId: 'memory_bytes_gauge', @@ -430,6 +452,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [ { title: intl.get('metric_description.process_context_open_file_desc'), valueType: VALUE_TYPE.number, + key: 'process_context_open_file_desc', queries: [ { refId: 'context_switches_total', diff --git a/src/utils/interface.ts b/src/utils/interface.ts index 10f78ec7..919f9035 100644 --- a/src/utils/interface.ts +++ b/src/utils/interface.ts @@ -178,4 +178,12 @@ export interface BatchQueryItem { start?: number; end?: number; step?: number; +} + +export interface MachinePanelConfig { + key: string; + title: string; + valueType: VALUE_TYPE; + showIndex?: number; + refIds: string[]; } \ No newline at end of file diff --git a/src/utils/promQL.ts b/src/utils/promQL.ts index 2d06b843..317f881c 100644 --- a/src/utils/promQL.ts +++ b/src/utils/promQL.ts @@ -26,67 +26,59 @@ export let SUPPORT_METRICS = valueType: VALUE_TYPE.percentage, }, { - metric: 'cpu_wait', + metric: 'cpu_io_wait_used', valueType: VALUE_TYPE.percentage, }, { - metric: 'cpu_user', + metric: 'cpu_user_used', valueType: VALUE_TYPE.percentage, }, { - metric: 'cpu_system', + metric: 'cpu_system_used', valueType: VALUE_TYPE.percentage, }, ], memory: [ - // { - // metric: 'memory_utilization', - // valueType: VALUE_TYPE.percentage, - // }, { - metric: 'memory_used_percentage', + metric: 'memory_used_utilization', valueType: VALUE_TYPE.percentage, }, { - metric: 'memory_used', - valueType: VALUE_TYPE.byte, + metric: 'memory_cached_utilization', + valueType: VALUE_TYPE.percentage, }, { - metric: 'memory_actual_used_percentage', + metric: 'memory_swap_utilization', valueType: VALUE_TYPE.percentage, }, { - metric: 'memory_actual_used', + metric: 'memory_used', valueType: VALUE_TYPE.byte, }, { - metric: 'memory_free', + metric: 'memory_cached', valueType: VALUE_TYPE.byte, }, { - metric: 'memory_swap_total', + metric: 'memory_swap_used', valueType: VALUE_TYPE.byte, }, { - metric: 'memory_cached_buffer_used', + metric: 'memory_swap_total', valueType: VALUE_TYPE.byte, }, - { - metric: 'memory_cached_buffer_used_percentage', - valueType: VALUE_TYPE.percentage, - }, ], load: [ { - metric: 'load_15s', + metric: 'load_1', valueType: VALUE_TYPE.number, }, { - metric: 'load_5m', + metric: 'load_5', valueType: VALUE_TYPE.number, }, { - metric: 'load_15m', + metric: 'load_15', valueType: VALUE_TYPE.number, }, ], @@ -162,55 +154,70 @@ export const getClusterPrefix = () => { export const diskPararms = 'fstype=~"ext.*|xfs",mountpoint !~".*pod.*"'; -export let LINUX = (cluster?, device?: string): any => { - const clusterSuffix1 = cluster ? `,${getClusterPrefix()}='${cluster}'` : ''; - const clusterSuffix2 = cluster ? `{${getClusterPrefix()}='${cluster}'}` : ''; - const devicePararms = device ? `,device=~"${device}"` : ''; - +const getPromqlLabel = (cluster?, device?: string, instance?: string) => { + const clusterSuffix = cluster ? `${getClusterPrefix()} = "${cluster}"` : ''; + const devicePararmSuffix = device ? `device=~"${device}"` : ''; + const instanceSuffix = instance ? `instance=~"^${instance.replaceAll(".", "\.")}.*"` : ''; + const promqlLabel = [clusterSuffix, devicePararmSuffix, instanceSuffix].reduce((x, y) => { + if (x.length > 0 && y.length > 0) { + return `${x},${y}`; + } + return x + y; + }); + return promqlLabel; +} +export let LINUX = (cluster?, device?: string, instance?: string): any => { + const suffix = getPromqlLabel(cluster, device, instance); + const suffix1 = suffix.length ? `,${suffix}` : ''; + const suffix2 = suffix.length ? `{${suffix}}` : ''; return { // cpu relative: - cpu_utilization: `100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"${clusterSuffix1}}[1m])) * 100)`, - cpu_idle: `avg by (instance) (irate(node_cpu_seconds_total{mode="idle"${clusterSuffix1}}[1m])) * 100`, - cpu_wait: `avg by (instance) (irate(node_cpu_seconds_total{mode="iowait"${clusterSuffix1}}[1m])) * 100`, - cpu_user: `avg by (instance) (irate(node_cpu_seconds_total{mode="user"${clusterSuffix1}}[1m])) * 100`, - cpu_system: `avg by (instance) (irate(node_cpu_seconds_total{mode="system"${clusterSuffix1}}[1m])) * 100`, + cpu_utilization: `100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"${suffix1}}[1m])) * 100)`, + cpu_idle: `avg by (instance) (irate(node_cpu_seconds_total{mode="idle"${suffix1}}[1m])) * 100`, + cpu_io_wait_used: `avg by (instance) (irate(node_cpu_seconds_total{mode="iowait"${suffix1}}[1m])) * 100`, + cpu_user_used: `avg by (instance) (irate(node_cpu_seconds_total{mode="user"${suffix1}}[1m])) * 100`, + cpu_system_used: `avg by (instance) (irate(node_cpu_seconds_total{mode="system"${suffix1}}[1m])) * 100`, // memory relative: - // memory_utilization: `(1 - node_memory_MemFree_bytes${clusterSuffix2} / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`, - memory_used_percentage: `((node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2}) / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`, - memory_used: `node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2}`, - memory_actual_used: `node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2} - node_memory_Buffers_bytes${clusterSuffix2} - node_memory_Cached_bytes${clusterSuffix2}`, - memory_actual_used_percentage: `((node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2} - node_memory_Buffers_bytes${clusterSuffix2} - node_memory_Cached_bytes${clusterSuffix2}) / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`, - memory_free: `node_memory_MemFree_bytes${clusterSuffix2}`, - memory_cached_buffer_used: `node_memory_Buffers_bytes${clusterSuffix2} + node_memory_Cached_bytes${clusterSuffix2}`, - memory_cached_buffer_used_percentage: `((node_memory_Buffers_bytes${clusterSuffix2} + node_memory_Cached_bytes${clusterSuffix2}) / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`, - memory_size: `node_memory_MemTotal_bytes${clusterSuffix2}`, - memory_swap_total: `node_memory_SwapTotal_bytes${clusterSuffix2}`, + memory_used_utilization: `((node_memory_MemTotal_bytes${suffix2} - node_memory_MemAvailable_bytes${suffix2}) / node_memory_MemTotal_bytes${suffix2} )* 100`, + memory_avaliable_utilization: `(node_memory_MemAvailable_bytes${suffix2} / node_memory_MemTotal_bytes${suffix2} )* 100`, + memory_cached_utilization: `(node_memory_Buffers_bytes${suffix2} + node_memory_Cached_bytes${suffix2}) / node_memory_MemTotal_bytes${suffix2} * 100`, + memory_swap_utilization: `(node_memory_SwapTotal_bytes${suffix2} - node_memory_SwapFree_bytes${suffix2}) / node_memory_MemTotal_bytes${suffix2} * 100`, + + memory_total: `node_memory_MemTotal_bytes${suffix2}`, + memory_used: `node_memory_MemTotal_bytes${suffix2} - node_memory_MemAvailable_bytes${suffix2}`, + memory_avaliable: `node_memory_MemAvailable_bytes${suffix2}`, + memory_cached: `node_memory_Buffers_bytes${suffix2} + node_memory_Cached_bytes${suffix2}`, + memory_swap_used: `node_memory_SwapTotal_bytes${suffix2} - node_memory_SwapFree_bytes${suffix2}`, + memory_swap_total: `node_memory_SwapTotal_bytes${suffix2}`, // node load relative: - load_15s: `node_load1${clusterSuffix2}`, - load_5m: `node_load5${clusterSuffix2}`, - load_15m: `node_load15${clusterSuffix2}`, + load_1: `node_load1${suffix2}`, + load_5: `node_load5${suffix2}`, + load_15: `node_load15${suffix2}`, // disk relative: - disk_used: `node_filesystem_size_bytes{${diskPararms}${devicePararms}${clusterSuffix1}} - node_filesystem_free_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}`, - disk_free: `node_filesystem_avail_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}`, - disk_readbytes: `irate(node_disk_read_bytes_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[1m])`, - disk_writebytes: `irate(node_disk_written_bytes_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[1m])`, - disk_readiops: `irate(node_disk_reads_completed_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[1m])`, - disk_writeiops: `irate(node_disk_writes_completed_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[1m])`, - inode_utilization: `(1- (node_filesystem_files_free{${diskPararms}${devicePararms}${clusterSuffix1}}) / (node_filesystem_files{mountpoint="/",fstype!="rootfs"${clusterSuffix1}})) * 100`, - disk_used_percentage: `(node_filesystem_size_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}-node_filesystem_free_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}) *100/(node_filesystem_avail_bytes {${diskPararms}${devicePararms}${clusterSuffix1}}+(node_filesystem_size_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}-node_filesystem_free_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}))`, - disk_size: `node_filesystem_size_bytes{${diskPararms}${devicePararms}${clusterSuffix1}}`, - root_fs_used_percentage: `100 - ((node_filesystem_avail_bytes{fstype!="rootfs"${clusterSuffix1}} * 100) / node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"${clusterSuffix1}})`, + disk_used: `node_filesystem_size_bytes${suffix2} - node_filesystem_free_bytes${suffix2}`, + disk_free: `node_filesystem_avail_bytes${suffix2}`, + disk_readbytes: `irate(node_disk_read_bytes_total${suffix2}[1m])`, + disk_writebytes: `irate(node_disk_written_bytes_total${suffix2}[1m])`, + disk_readiops: `irate(node_disk_reads_completed_total${suffix2}[1m])`, + disk_writeiops: `irate(node_disk_writes_completed_total${suffix2}[1m])`, + inode_utilization: `(1- (node_filesystem_files_free${suffix2}) / (node_filesystem_files{mountpoint="/",fstype!="rootfs"${suffix1}})) * 100`, + disk_used_percentage: `(node_filesystem_size_bytes${suffix2}-node_filesystem_free_bytes${suffix2}) *100/(node_filesystem_avail_bytes${suffix2}+(node_filesystem_size_bytes${suffix2}-node_filesystem_free_bytes${suffix2}))`, + disk_size: `node_filesystem_size_bytes${suffix2}`, + root_fs_used_percentage: `100 - ((node_filesystem_avail_bytes{fstype!="rootfs"${suffix1}} * 100) / node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"${suffix1}})`, - network_in_rate: `ceil(sum by(instance)(irate(node_network_receive_bytes_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[1m])))`, - network_out_rate: `ceil(sum by(instance)(irate(node_network_transmit_bytes_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[1m])))`, - network_in_errs: `ceil(sum by(instance)(irate(node_network_receive_errs_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[1m])))`, - network_out_errs: `ceil(sum by(instance)(irate(node_network_transmit_errs_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[1m])))`, - network_in_packets: `ceil(sum by(instance)(irate(node_network_receive_packets_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[1m])))`, - network_out_packets: `ceil(sum by(instance)(irate(node_network_transmit_packets_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[1m])))`, + network_in_rate: `ceil(sum by(instance)(irate(node_network_receive_bytes_total{device=~"(eth|en)[a-z0-9]*"${suffix1}}[1m])))`, + network_out_rate: `ceil(sum by(instance)(irate(node_network_transmit_bytes_total{device=~"(eth|en)[a-z0-9]*"${suffix1}}[1m])))`, + network_in_errs: `ceil(sum by(instance)(irate(node_network_receive_errs_total{device=~"(eth|en)[a-z0-9]*"${suffix1}}[1m])))`, + network_out_errs: `ceil(sum by(instance)(irate(node_network_transmit_errs_total{device=~"(eth|en)[a-z0-9]*"${suffix1}}[1m])))`, + network_in_packets: `ceil(sum by(instance)(irate(node_network_receive_packets_total{device=~"(eth|en)[a-z0-9]*"${suffix1}}[1m])))`, + network_out_packets: `ceil(sum by(instance)(irate(node_network_transmit_packets_total{device=~"(eth|en)[a-z0-9]*"${suffix1}}[1m])))`, + + open_file_desc: `node_filefd_allocated${suffix2}`, + context_switch_rate: `irate(node_context_switches_total${suffix2}[30s])` } }; @@ -260,19 +267,19 @@ export let getNodeInfoQueries = (clusterId?) => { }, { refId: "diskMaxRead", - query: `max(rate(node_disk_read_bytes_total${clusterSuffix2}[30s])) by (instance)` + query: `max(irate(node_disk_read_bytes_total${clusterSuffix2}[30s])) by (instance)` }, { refId: "diskMaxWrite", - query: `max(rate(node_disk_written_bytes_total${clusterSuffix2}[30s])) by (instance)` + query: `max(irate(node_disk_written_bytes_total${clusterSuffix2}[30s])) by (instance)` }, { refId: "networkIn", - query: `max(rate(node_network_receive_bytes_total${clusterSuffix2}[30s])*8) by (instance)` + query: `max(irate(node_network_receive_bytes_total${clusterSuffix2}[30s])*8) by (instance)` }, { refId: "networkOut", - query: `max(rate(node_network_transmit_bytes_total${clusterSuffix2}[30s])*8) by (instance)` + query: `max(irate(node_network_transmit_bytes_total${clusterSuffix2}[30s])*8) by (instance)` }, { refId: "memoryUsed", @@ -393,11 +400,11 @@ export const getMachineMetricData = (instance, cluster) => { queries: [ { refId: 'disk_read_rate', - query: `rate(node_disk_reads_completed_total{${instanceSuffix}${clusterSuffix1}}[1m])`, + query: `irate(node_disk_reads_completed_total{${instanceSuffix}${clusterSuffix1}}[1m])`, }, { refId: 'disk_write_rate', - query: `rate(node_disk_writes_completed_total{${instanceSuffix}${clusterSuffix1}}[1m])`, + query: `irate(node_disk_writes_completed_total{${instanceSuffix}${clusterSuffix1}}[1m])`, }, ] }, @@ -408,11 +415,11 @@ export const getMachineMetricData = (instance, cluster) => { queries: [ { refId: 'disk_read_rate', - query: `rate(node_disk_read_bytes_total{${instanceSuffix}${clusterSuffix1}}[1m])`, + query: `irate(node_disk_read_bytes_total{${instanceSuffix}${clusterSuffix1}}[1m])`, }, { refId: 'disk_write_rate', - query: `rate(node_disk_written_bytes_total{${instanceSuffix}${clusterSuffix1}}[1m])`, + query: `irate(node_disk_written_bytes_total{${instanceSuffix}${clusterSuffix1}}[1m])`, }, ] }, @@ -442,7 +449,7 @@ export const getMachineMetricData = (instance, cluster) => { }, { refId: 'context_switch_rate', - query: `rate(node_context_switches_total{${instanceSuffix}${clusterSuffix1}}[30s])`, + query: `irate(node_context_switches_total{${instanceSuffix}${clusterSuffix1}}[30s])`, } ] }