diff --git a/src/utils/metric.ts b/src/utils/metric.ts index 07b6caef..da7527ba 100644 --- a/src/utils/metric.ts +++ b/src/utils/metric.ts @@ -191,15 +191,15 @@ export const getRawQueryByAggregation = (aggregation: AggregationType, metric: s case AggregationType.Sum: return `sum(${metric})`; case AggregationType.Rate: - return `rate(${metric}[1m])`; + return `rate(${metric}[5s])`; case AggregationType.P75: - return `quantile(0.75, sum(rate(${metric}[1m])) by (instance))` + return `quantile(0.75, sum(rate(${metric}[5s])) by (instance))` case AggregationType.P95: - return `quantile(0.95, sum(rate(${metric}[1m])) by (instance))` + return `quantile(0.95, sum(rate(${metric}[5s])) by (instance))` case AggregationType.P99: - return `quantile(0.99, sum(rate(${metric}[1m])) by (instance))` + return `quantile(0.99, sum(rate(${metric}[5s])) by (instance))` case AggregationType.P999: - return `quantile(0.999, sum(rate(${metric}[1m])) by (instance))` + return `quantile(0.999, sum(rate(${metric}[5s])) by (instance))` } } diff --git a/src/utils/promQL.ts b/src/utils/promQL.ts index adb81a28..3568d5e8 100644 --- a/src/utils/promQL.ts +++ b/src/utils/promQL.ts @@ -55,7 +55,7 @@ export let SUPPORT_METRICS = ], load: [ { - metric: 'load_1m', + metric: 'load_15s', valueType: VALUE_TYPE.number, }, { @@ -143,11 +143,11 @@ export let LINUX = (cluster?, device?: string): any => { return { // cpu relative: - cpu_utilization: `100 * (1 - sum by (instance)(increase(node_cpu_seconds_total{mode="idle"${clusterSuffix1}}[1m])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[1m])))`, - cpu_idle: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="idle"${clusterSuffix1}}[1m])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[1m])))`, - cpu_wait: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="iowait"${clusterSuffix1}}[1m])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[1m])))`, - cpu_user: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="user"${clusterSuffix1}}[1m])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[1m])))`, - cpu_system: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="system"${clusterSuffix1}}[1m])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[1m])))`, + cpu_utilization: `100 * (1 - sum by (instance)(increase(node_cpu_seconds_total{mode="idle"${clusterSuffix1}}[15s])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[15s])))`, + cpu_idle: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="idle"${clusterSuffix1}}[15s])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[15s])))`, + cpu_wait: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="iowait"${clusterSuffix1}}[15s])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[15s])))`, + cpu_user: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="user"${clusterSuffix1}}[15s])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[15s])))`, + cpu_system: `100 * (sum by (instance)(increase(node_cpu_seconds_total{mode="system"${clusterSuffix1}}[15s])) / sum by (instance)(increase(node_cpu_seconds_total${clusterSuffix2}[15s])))`, // memory relative: memory_utilization: `(1 - node_memory_MemFree_bytes${clusterSuffix2} / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`, @@ -157,27 +157,27 @@ export let LINUX = (cluster?, device?: string): any => { memory_size: `node_memory_MemTotal_bytes${clusterSuffix2}`, // node load relative: - load_1m: `node_load1${clusterSuffix2}`, + load_15s: `node_load1${clusterSuffix2}`, load_5m: `node_load5${clusterSuffix2}`, load_15m: `node_load15${clusterSuffix2}`, // 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])`, + disk_readbytes: `irate(node_disk_read_bytes_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[15s])`, + disk_writebytes: `irate(node_disk_written_bytes_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[15s])`, + disk_readiops: `irate(node_disk_reads_completed_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[15s])`, + disk_writeiops: `irate(node_disk_writes_completed_total{${devicePararms ? devicePararms : 'device=~"(sd|nvme|hd)[a-z0-9]*"'}${clusterSuffix1}}[15s])`, 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}}`, - 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]*"${clusterSuffix1}}[15s])))`, + network_out_rate: `ceil(sum by(instance)(irate(node_network_transmit_bytes_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[15s])))`, + network_in_errs: `ceil(sum by(instance)(irate(node_network_receive_errs_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[15s])))`, + network_out_errs: `ceil(sum by(instance)(irate(node_network_transmit_errs_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[15s])))`, + network_in_packets: `ceil(sum by(instance)(irate(node_network_receive_packets_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[15s])))`, + network_out_packets: `ceil(sum by(instance)(irate(node_network_transmit_packets_total{device=~"(eth|en)[a-z0-9]*"${clusterSuffix1}}[15s])))`, } }; @@ -193,6 +193,6 @@ export const updatePromql = (service: { // const clusterSuffix = cluster ? `${getClusterPrefix()}='${cluster}'` : ''; // return { // // cpu_utilization -// "cpu_used": `100 * sum by (nebula_cluster)(increase(nebula_graphd_cpu_seconds_total{${clusterSuffix}}[1m])) / sum by (nebula_cluster)(increase(node_cpu_seconds_total{${clusterSuffix}}[1m]))`, +// "cpu_used": `100 * sum by (nebula_cluster)(increase(nebula_graphd_cpu_seconds_total{${clusterSuffix}}[15s])) / sum by (nebula_cluster)(increase(node_cpu_seconds_total{${clusterSuffix}}[15s]))`, // } // } \ No newline at end of file