Skip to content

Commit

Permalink
update launchpad cpu/mem usage (labring#5016)
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyxjh authored and zjy365 committed Sep 3, 2024
1 parent 951cbf5 commit 0570e1d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions service/launchpad/request/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func GetQuery(query *api.VMRequest) (string, error) {
var result string
switch query.Type {
case "cpu":
result = "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod)*100,0.01)"
result = "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod)*100,0.01)"
case "memory":
result = "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) * 100, 0.01)"
result = "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"$namespace\",pod=~\"$pod.*\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) * 100, 0.01)"
case "average_cpu":
result = "avg(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod)*100,0.01)"
result = "avg(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod)*100,0.01)"
case "average_memory":
result = "avg(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) * 100, 0.01)"
result = "avg(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"$namespace\",pod=~\"$pod.*\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"$namespace\",pod=~\"$pod.*\"}) by (pod) * 100, 0.01)"
default:
log.Println(query.Type)
}
Expand Down

0 comments on commit 0570e1d

Please sign in to comment.