Skip to content

Commit

Permalink
Modify cpu query for rancher cluster (#90)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <arnob@appscode.com>
  • Loading branch information
ArnobKumarSaha authored Oct 1, 2024
1 parent 686fcc3 commit b98120e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ import (
func GetPodResourceUsage(pc promv1.API, obj metav1.ObjectMeta) core.ResourceList {
resUsage := core.ResourceList{}

promCPUQuery := fmt.Sprintf(`sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace="%s", pod="%s", container!=""})`, obj.Namespace, obj.Name)
// Previous way: sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace="%s", pod="%s", container!=""})
promCPUQuery := fmt.Sprintf(`sum(
sum by (namespace, pod, container) (
irate(container_cpu_usage_seconds_total{image!="",metrics_path="/metrics/cadvisor",namespace="%s", pod="%s"}[5m])
)
* on (namespace, pod) group_left (node)
topk by (namespace, pod) (1,
max by (namespace, pod, node) (
kube_pod_info{node!="",namespace="%s", pod="%s"}
)
)
) by (pod)`, obj.Namespace, obj.Name, obj.Namespace, obj.Name)
promMemoryQuery := fmt.Sprintf(`sum(container_memory_working_set_bytes{namespace="%s", pod="%s", container!="", image!=""})`, obj.Namespace, obj.Name)
promStorageQuery := fmt.Sprintf(`avg(container_blkio_device_usage_total{namespace="%s", pod="%s"})`, obj.Namespace, obj.Name)

Expand Down

0 comments on commit b98120e

Please sign in to comment.