|
|
@@ -389,6 +389,7 @@ type Node struct {
|
|
|
CPUCost float64
|
|
|
CPUCores float64
|
|
|
GPUCost float64
|
|
|
+ GPUCount float64
|
|
|
RAMCost float64
|
|
|
RAMBytes float64
|
|
|
Discount float64
|
|
|
@@ -449,7 +450,8 @@ func ClusterNodes(cp cloud.Provider, client prometheus.Client, duration, offset
|
|
|
queryNodeCPUCores := fmt.Sprintf(`avg_over_time(avg(kube_node_status_capacity_cpu_cores) by (cluster_id, node)[%s:%dm]%s)`, durationStr, minsPerResolution, offsetStr)
|
|
|
queryNodeRAMCost := fmt.Sprintf(`sum_over_time((avg(kube_node_status_capacity_memory_bytes) by (cluster_id, node) * on(cluster_id, node) group_right avg(node_ram_hourly_cost) by (cluster_id, node, instance_type, provider_id))[%s:%dm]%s) / 1024 / 1024 / 1024 * %f`, durationStr, minsPerResolution, offsetStr, hourlyToCumulative)
|
|
|
queryNodeRAMBytes := fmt.Sprintf(`avg_over_time(avg(kube_node_status_capacity_memory_bytes) by (cluster_id, node)[%s:%dm]%s)`, durationStr, minsPerResolution, offsetStr)
|
|
|
- queryNodeGPUCost := fmt.Sprintf(`sum_over_time((avg(node_gpu_hourly_cost * %d.0 / 60.0) by (cluster_id, node, provider_id))[%s:%dm]%s)`, minsPerResolution, durationStr, minsPerResolution, offsetStr)
|
|
|
+ queryNodeGPUCost := fmt.Sprintf(`sum_over_time((avg(node_gpu_count) by (cluster_id, node) * on(node, cluster_id) group_right avg(node_gpu_hourly_cost) by (cluster_id, node, instance_type, provider_id))[%s:%dm]%s) * %f`, durationStr, minsPerResolution, offsetStr, hourlyToCumulative)
|
|
|
+ queryNodeGPUCount := fmt.Sprintf(`avg_over_time(avg(node_gpu_count) by (cluster_id, node)[%s:%dm]%s)`, durationStr, minsPerResolution, offsetStr)
|
|
|
queryNodeCPUModeTotal := fmt.Sprintf(`sum(rate(node_cpu_seconds_total[%s:%dm]%s)) by (kubernetes_node, cluster_id, mode)`, durationStr, minsPerResolution, offsetStr)
|
|
|
queryNodeRAMSystemPct := fmt.Sprintf(`sum(sum_over_time(container_memory_working_set_bytes{container_name!="POD",container_name!="",namespace="kube-system"}[%s:%dm]%s)) by (instance, cluster_id) / avg(label_replace(sum(sum_over_time(kube_node_status_capacity_memory_bytes[%s:%dm]%s)) by (node, cluster_id), "instance", "$1", "node", "(.*)")) by (instance, cluster_id)`, durationStr, minsPerResolution, offsetStr, durationStr, minsPerResolution, offsetStr)
|
|
|
queryNodeRAMUserPct := fmt.Sprintf(`sum(sum_over_time(container_memory_working_set_bytes{container_name!="POD",container_name!="",namespace!="kube-system"}[%s:%dm]%s)) by (instance, cluster_id) / avg(label_replace(sum(sum_over_time(kube_node_status_capacity_memory_bytes[%s:%dm]%s)) by (node, cluster_id), "instance", "$1", "node", "(.*)")) by (instance, cluster_id)`, durationStr, minsPerResolution, offsetStr, durationStr, minsPerResolution, offsetStr)
|
|
|
@@ -463,6 +465,7 @@ func ClusterNodes(cp cloud.Provider, client prometheus.Client, duration, offset
|
|
|
resChNodeRAMCost := requiredCtx.Query(queryNodeRAMCost)
|
|
|
resChNodeRAMBytes := requiredCtx.Query(queryNodeRAMBytes)
|
|
|
resChNodeGPUCost := requiredCtx.Query(queryNodeGPUCost)
|
|
|
+ resChNodeGPUCount := requiredCtx.Query(queryNodeGPUCount)
|
|
|
resChActiveMins := requiredCtx.Query(queryActiveMins)
|
|
|
resChIsSpot := requiredCtx.Query(queryIsSpot)
|
|
|
|
|
|
@@ -475,6 +478,7 @@ func ClusterNodes(cp cloud.Provider, client prometheus.Client, duration, offset
|
|
|
resNodeCPUCost, _ := resChNodeCPUCost.Await()
|
|
|
resNodeCPUCores, _ := resChNodeCPUCores.Await()
|
|
|
resNodeGPUCost, _ := resChNodeGPUCost.Await()
|
|
|
+ resNodeGPUCount, _ := resChNodeGPUCount.Await()
|
|
|
resNodeRAMCost, _ := resChNodeRAMCost.Await()
|
|
|
resNodeRAMBytes, _ := resChNodeRAMBytes.Await()
|
|
|
resIsSpot, _ := resChIsSpot.Await()
|
|
|
@@ -506,6 +510,7 @@ func ClusterNodes(cp cloud.Provider, client prometheus.Client, duration, offset
|
|
|
|
|
|
cpuCoresMap := buildCPUCoresMap(resNodeCPUCores, clusterAndNameToType)
|
|
|
|
|
|
+ gpuCountMap := buildGPUCountMap(resNodeGPUCount)
|
|
|
ramBytesMap := buildRAMBytesMap(resNodeRAMBytes)
|
|
|
|
|
|
ramUserPctMap := buildRAMUserPctMap(resNodeRAMUserPct)
|
|
|
@@ -518,7 +523,7 @@ func ClusterNodes(cp cloud.Provider, client prometheus.Client, duration, offset
|
|
|
|
|
|
nodeMap := buildNodeMap(
|
|
|
cpuCostMap, ramCostMap, gpuCostMap,
|
|
|
- cpuCoresMap, ramBytesMap, ramUserPctMap,
|
|
|
+ cpuCoresMap, ramBytesMap, ramUserPctMap, gpuCountMap,
|
|
|
ramSystemPctMap,
|
|
|
cpuBreakdownMap,
|
|
|
activeDataMap,
|