通过 `container_swap_usage_bytes` 指标收集交换使用情况
kubectl get --raw "/api/v1/nodes//proxy/metrics/resource"
HELP container_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the container in core-seconds
TYPE container_cpu_usage_seconds_total counter
container_cpu_usage_seconds_total{container="c1",namespace="default",pod="test-pod"} 128.476535 1687950863878 container_cpu_usage_seconds_total{container="coredns",namespace="kube-system",pod="coredns-8f5847b64-t9gmr"} 0.915609 1687950855483
HELP container_memory_working_set_bytes [ALPHA] Current working set of the container in bytes
TYPE container_memory_working_set_bytes gauge
container_memory_working_set_bytes{container="c1",namespace="default",pod="test-pod"} 3.92847388672e+11 1687950863878 container_memory_working_set_bytes{container="coredns",namespace="kube-system",pod="coredns-8f5847b64-t9gmr"} 1.5310848e+07 1687950855483
HELP container_start_time_seconds [ALPHA] Start time of the container since unix epoch in seconds
TYPE container_start_time_seconds gauge
container_start_time_seconds{container="c1",namespace="default",pod="test-pod"} 1.6879504889662333e+09 1687950488966 container_start_time_seconds{container="coredns",namespace="kube-system",pod="coredns-8f5847b64-t9gmr"} 1.6879504537882898e+09 1687950453788
HELP container_swap_usage_bytes [ALPHA] Current container amount of swap usage in bytes
TYPE container_swap_usage_bytes gauge
container_swap_usage_bytes{container="c1",namespace="default",pod="test-pod"} 3.4400333824e+10 1687950863878 container_swap_usage_bytes{container="coredns",namespace="kube-system",pod="coredns-8f5847b64-t9gmr"} 0 1687950855483
HELP node_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the node in core-seconds
TYPE node_cpu_usage_seconds_total counter
node_cpu_usage_seconds_total 45770.147028 1687950863599
HELP node_memory_working_set_bytes [ALPHA] Current working set of the node in bytes
TYPE node_memory_working_set_bytes gauge
node_memory_working_set_bytes 3.95755573248e+11 1687950863599
HELP node_swap_usage_bytes [ALPHA] Current node swap usage in bytes
TYPE node_swap_usage_bytes gauge
node_swap_usage_bytes 1.8446743709127774e+19 1687950863599
HELP pod_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the pod in core-seconds
TYPE pod_cpu_usage_seconds_total counter
pod_cpu_usage_seconds_total{namespace="default",pod="test-pod"} 123.291472 1687950858784 pod_cpu_usage_seconds_total{namespace="kube-system",pod="coredns-8f5847b64-t9gmr"} 5.101812 1687950863144
内容来源: kubernetes-sigs/metrics-server