Example of Querying Aggregation Metrics
You can use Prometheus statements to combine basic metrics into aggregation metrics so that you can query object resource information quickly. This topic provides some aggregation metrics, including vCPU usage, memory usage, disk usage, disk read/write rate, network transmission error rate, network packet loss rate, and network transmit/receive rate. The metrics can be queried by Deployment, pod, and container. The aggregation metrics described in the table are only for reference. You can query other aggregation metrics using Prometheus statement. For details about the Prometheus statement syntax, visit the Prometheus official website.
Category |
Name |
Description |
Implementation |
vCPU metrics |
deployment_cpu_usage |
Queries the vCPU usages of Deployments. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(rate(container_cpu_usage_seconds_total{image!=""}[5m])) / sum by(pod,namespace)(container_spec_cpu_quota{image!=""} /100000)) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
Queries the vCPU usage of a Deployment. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(rate(container_cpu_usage_seconds_total{image!=""}[5m])) / sum by(pod,namespace)(container_spec_cpu_quota{image!=""} /100000)) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_name =~ '{DEPLOYMENTNAME}.*',created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
||
pod_cpu_usage |
Queries the vCPU usages of pods. |
sum(rate(container_cpu_usage_seconds_total{image != ""}[5m])) by (pod, namespace) / (sum(container_spec_cpu_quota{image != ""}/100000) by (pod, namespace)) * 100 |
|
Queries the vCPU usage of a pod. |
sum(rate(container_cpu_usage_seconds_total{image != "",pod="{PODNAME}"}[5m])) by (pod, namespace) / (sum(container_spec_cpu_quota{image != "",pod="{PODNAME}"}/100000) by (pod, namespace)) * 100 |
||
container_cpu_usage |
Queries the vCPU usages of containers. |
sum(rate(container_cpu_usage_seconds_total{image != ""}[5m])) by (pod,namespace,container) / (sum(container_spec_cpu_quota{image != ""}/100000) by (pod,namespace,container)) * 100 |
|
Queries the vCPU usage of a container. |
sum(rate(container_cpu_usage_seconds_total{image != "",pod="{PODNAME}",container="{CONTAINERNAME}"}[5m])) by (pod,namespace,container) / (sum(container_spec_cpu_quota{image != "",pod="{PODNAME}",container="{CONTAINERNAME}"}/100000) by (pod,namespace,container)) * 100 |
||
Memory metrics |
deployment_memory_usage |
Queries the memory usages of Deployments. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_memory_working_set_bytes{image!=""}) / sum by(pod,namespace)(container_spec_memory_limit_bytes{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
Queries the memory usage of a Deployment. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_memory_working_set_bytes{image!=""}) / sum by(pod,namespace)(container_spec_memory_limit_bytes{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_name =~ '{DEPLOYMENTNAME}.*',created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
||
pod_memory_usage |
Queries the memory usages of pods. |
sum(container_memory_working_set_bytes{container!=""}) by (pod, namespace) / (sum(container_spec_memory_limit_bytes{container!=""}) by (pod, namespace)) * 100 |
|
Queries the memory usage of a pod. |
sum(container_memory_working_set_bytes{container!="",pod="{PODNAME}"}) by (pod, namespace) / (sum(container_spec_memory_limit_bytes{container!="",pod="{PODNAME}"}) by (pod, namespace)) * 100 |
||
container_memory_usage |
Queries the memory usages of containers. |
sum(container_memory_working_set_bytes{container!=""}) by (pod, namespace,container) / (sum(container_spec_memory_limit_bytes{container!=""}) by (pod, namespace,container)) * 100 |
|
Queries the memory usage of a container. |
sum(container_memory_working_set_bytes{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}) by (pod, namespace,container) / (sum(container_spec_memory_limit_bytes{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}) by (pod, namespace,container)) * 100 |
||
File system or disk metrics |
deployment_disk_usage |
Queries the disk usages of Deployments. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_fs_usage_bytes{image!=""}) / sum by(pod,namespace)(container_fs_limit_bytes{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
Queries the disk usage of a Deployment. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_fs_usage_bytes{image!=""}) / sum by(pod,namespace)(container_fs_limit_bytes{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_name =~ '{DEPLOYMENTNAME}.*',created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
||
pod_disk_usage |
Queries the disk usages of pods. |
(sum(container_fs_usage_bytes{container!=""}) by (pod)) / (sum(container_fs_limit_bytes{container!=""}) by (pod)) * 100 |
|
Queries the disk usage of a pod. |
(sum(container_fs_usage_bytes{container!="",pod="{PODNAME}"}) by (pod)) / (sum(container_fs_limit_bytes{container!="",pod="{PODNAME}"}) by (pod)) * 100 |
||
container_disk_usage |
Queries the disk usages of containers. |
(sum(container_fs_usage_bytes{container!=""}) by (pod,container)) / (sum(container_fs_limit_bytes{container!=""}) by (pod,container)) * 100 |
|
Queries the disk usage of a container. |
(sum(container_fs_usage_bytes{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}) by (pod,container)) / (sum(container_fs_limit_bytes{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}) by (pod,container)) * 100 |
||
disk_read_kilobytes |
Queries the disk read rate. |
sum(rate(container_fs_reads_total{container!=""}[5m])) by(namespace) |
|
disk_write_kilobytes |
Queries the disk write rate. |
sum(rate(container_fs_writes_total{container!=""}[5m])) by(namespace) |
|
Network metrics |
deployment_network_transmit_error_packets |
Queries the transmission error rates of Deployments. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_network_transmit_packets_dropped_total{image!=""}) / sum by(pod,namespace)(container_network_transmit_packets_total{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
Queries the transmission error rate of a Deployment. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_network_transmit_packets_dropped_total{image!=""}) / sum by(pod,namespace)(container_network_transmit_packets_total{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_name =~ '{DEPLOYMENTNAME}.*',created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
||
pod_network_transmit_error_packets |
Queries the transmission error rates of pods. |
sum(rate(container_network_transmit_packets_dropped_total{container!=""}[5m])) by(namespace,pod)/sum(rate(container_network_transmit_packets_total{container!=""}[5m])) by(namespace,pod)* 100 |
|
Queries the transmission error rate of a pod. |
sum(rate(container_network_transmit_packets_dropped_total{container!="",pod="{PODNAME}"}[5m])) by(namespace,pod)/sum(rate(container_network_transmit_packets_total{container!="",pod="{PODNAME}"}[5m])) by(namespace,pod)* 100 |
||
container_network_transmit_error_packets |
Queries the transmission error rates of containers. |
sum(rate(container_network_transmit_packets_dropped_total{container!=""}[5m])) by(namespace,pod,container)/sum(rate(container_network_transmit_packets_total{container!=""}[5m])) by(namespace,pod,container)* 100 |
|
Queries the transmission error rate of a container. |
sum(rate(container_network_transmit_packets_dropped_total{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}[5m])) by(namespace,pod,container)/sum(rate(container_network_transmit_packets_total{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}[5m])) by(namespace,pod,container)* 100 |
||
deployment_network_receive_error_packets |
Queries the packet loss rates of Deployments. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_network_receive_packets_dropped_total{image!=""}) / sum by(pod,namespace)(container_network_receive_packets_total{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
|
Queries the packet loss rate of a Deployment. |
label_replace(sum by (created_by_name,namespace)((sum by (pod,namespace)(container_network_receive_packets_dropped_total{image!=""}) / sum by(pod,namespace)(container_network_receive_packets_total{image!=""})) *on(pod,namespace) group_left(created_by_kind,created_by_name) (count by (pod,created_by_kind,created_by_name,namespace)(kube_pod_info{created_by_name =~ '{DEPLOYMENTNAME}.*',created_by_kind='ReplicaSet'}))),"deployment","$1","created_by_name","(.*)-[^-]*")*100 |
||
pod_network_receive_error_packets |
Queries the packet loss rates of pods. |
sum(rate(container_network_receive_packets_dropped_total{container!=""}[5m])) by(namespace,pod)/sum(rate(container_network_receive_packets_total{container!=""}[5m])) by(namespace,pod)* 100 |
|
Queries the packet loss rate of a pod. |
sum(rate(container_network_receive_packets_dropped_total{container!="",pod="{PODNAME}"}[5m])) by(namespace,pod)/sum(rate(container_network_receive_packets_total{container!="",pod="{PODNAME}"}[5m])) by(namespace,pod)* 100 |
||
container_network_receive_error_packets |
Queries the packet loss rates of containers. |
sum(rate(container_network_receive_packets_dropped_total{container!=""}[5m])) by(namespace,pod,container)/sum(rate(container_network_receive_packets_total{container!=""}[5m])) by(namespace,pod,container)* 100 |
|
Queries the packet loss rate of a container. |
sum(rate(container_network_receive_packets_dropped_total{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}[5m])) by(namespace,pod,container)/sum(rate(container_network_receive_packets_total{container!="",pod="{PODNAME}",container="{CONTAINERNAME}"}[5m])) by(namespace,pod,container)* 100 |
||
network_transmit_bytes |
Queries the network transmit rate. |
sum(rate(container_network_transmit_bytes_total{container!=""}[5m])) by(namespace) |
|
network_receive_bytes |
Queries the network receive rate. |
sum(rate(container_network_receive_bytes_total{container!=""}[5m])) by(namespace) |

- When querying a single Deployment, change {DEPLOYMENTNAME} in the statement to the name of the Deployment to be queried.
- When querying a single pod, change {PODNAME} in the statement to the name of the pod to be queried.
- When querying a single container, change {PODNAME} in the statement to the name of the pod where the container is running and {CONTAINERNAME} to the name of the container to be queried.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot