From 6c2f3f2bb8dc7f67d0843e19bb2a205c2c759d42 Mon Sep 17 00:00:00 2001 From: tzwang Date: Wed, 7 Dec 2022 05:57:58 +0800 Subject: [PATCH] fix --- app/overview.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/overview.go b/app/overview.go index 82c6ccc..225147c 100644 --- a/app/overview.go +++ b/app/overview.go @@ -45,16 +45,16 @@ const ( nvidia_smi_utilization_gpu_ratio = "nvidia_smi_utilization_gpu_ratio{cluster_name='clusterName'}" nvidia_smi_utilization_memory_ratio = "nvidia_smi_utilization_memory_ratio{cluster_name='clusterName'}" - ClusterName = "clusterName" - metric_range_1s = "1s" - steps_1s = 100 - buffer = 5 - cpu_avg_usage = "avg_over_time(sum by (cluster) (node:node_num_cpu:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'} * node:node_cpu_utilisation:avg1m{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'})[7d])" - mem_avg_usage = "avg_over_time(sum by (cluster) (node:node_memory_bytes_total:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'} - node:node_memory_bytes_available:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'})[7d])" - cpu_total_usage = "round(:node_cpu_utilisation:avg1m{cluster_name='clusterName'} * sum(node:node_num_cpu:sum{cluster_name='clusterName'}), 0.001) " - mem_total_usage = "sum(node:node_memory_bytes_total:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'}) - sum(node:node_memory_bytes_available:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'})" - metric_range_7d = "168h" - steps_7d = 90000 + ClusterName = "clusterName" + metric_range_1s = "1s" + steps_1s = 100 + buffer = 5 + cpu_avg_usage = "avg_over_time(sum by (cluster) (node:node_num_cpu:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'} * node:node_cpu_utilisation:avg1m{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'})[7d])" + mem_avg_usage = "avg_over_time(sum by (cluster) (node:node_memory_bytes_total:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'} - node:node_memory_bytes_available:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'})[7d])" + cpu_total_usage = "round(:node_cpu_utilisation:avg1m{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'} * sum(node:node_num_cpu:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'}), 0.001) " + mem_total_usage = "sum(node:node_memory_bytes_total:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'}) - sum(node:node_memory_bytes_available:sum{cluster_name='clusterName',prometheus_replica='prometheus-k8s-0'})" + metric_range_temp = "72h" + steps_temp = 7000 ) type Overview struct { @@ -432,10 +432,10 @@ func GetOverallMetrics(c *gin.Context) { } metricMap := map[string][]MetricUrl{ - "cpu_avg_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["cpu_avg_usage"], "+"), nil, "", metric_range_7d, steps_7d)}}, - "mem_avg_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["mem_avg_usage"], "+"), nil, "", metric_range_7d, steps_7d)}}, - "cpu_total_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["cpu_total_usage"], "+"), nil, "", metric_range_7d, steps_7d)}}, - "mem_total_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["mem_total_usage"], "+"), nil, "", metric_range_7d, steps_7d)}}, + "cpu_avg_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["cpu_avg_usage"], "+"), nil, "", metric_range_temp, steps_temp)}}, + "mem_avg_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["mem_avg_usage"], "+"), nil, "", metric_range_temp, steps_temp)}}, + "cpu_total_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["cpu_total_usage"], "+"), nil, "", metric_range_temp, steps_temp)}}, + "mem_total_usage": {{ClusterName, "", GetMetricUrl(strings.TrimRight(imap["mem_total_usage"], "+"), nil, "", metric_range_temp, steps_temp)}}, } ch := make(chan MetricResult, len(metricMap))