cadvisor 常用容器監控指標

 https://github.com/google/cadvisor  (cAdvisor)

 

 

 

前提概念:

1.時間序列是指將同一統計指標的數值按其發生的時間先後順序排列而成的數列

2.     

=:選擇正好相等的字符串標籤

!=:選擇不相等的字符串標籤

=~:選擇匹配正則表達式的標籤(或子標籤)

!~:選擇不匹配正則表達式的標籤(或子標籤)

3.

s:seconds

m:minutes

h:hours

d:days

w:weeks

y:years

       注: [5m]指過去的5分鐘內

4.操作符

bool

and

or

unless

on

without : without(label)在結果中移除括號內的標籤和值

by : by(label)在結果中只保留括號內的標籤和值

 

1.網絡流量

接收字節(1分鐘內):

sum(rate(container_network_receive_bytes_total{id="/"}[1m])) by (id)

## container_network_receive_bytes_total:Cumulative count of bytes received

                                                                       (接收的字節數)

## id="/" : 容器ID = / ,根據ID查詢,也可根據名稱查詢 name=~".+"

 

上傳字節(1分鐘內):

sum(rate(container_network_transmit_bytes_total{id="/"}[1m])) by (id)

## container_network_transmit_bytes_total:Cumulative count of bytes transmitted

                                                                        (傳輸的字節數)

 

2.正在運行的容器數量

count(rate(container_last_seen{id=~".+",$label=~".+"}[1m]))

##  container_last_seen: Last time a container was seen by the exporter

## $label : 標籤條件,即按照擁有$label標籤的項查詢

##  .+ :通配

## container_group :待研究

 

3.容器 CPU相關

sum(rate(container_cpu_system_seconds_total[1m]))

## container_cpu_system_seconds_total :Cumulative system cpu time consumed in seconds

 

sum(rate(container_cpu_system_seconds_total{name=~".+"}[1m]))

sum(rate(container_cpu_system_seconds_total{id="/"}[1m]))

 

sum(rate(process_cpu_seconds_total[1m])) * 100

## process_cpu_seconds_total :Total user and system CPU time spent in seconds

 

sum(rate(container_cpu_system_seconds_total{name=~".+"}[1m])) + sum(rate(container_cpu_system_seconds_total{id="/"}[1m])) + sum(rate(process_cpu_seconds_total[1m]))

 

每個容器的cpu使用率:

sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100

## container_cpu_usage_seconds_total :Cumulative cpu time consumed per cpu in seconds

全部容器的CPU使用率總和:

sum(sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100)

 

total CPU Usage:

(* 待驗證)sum(rate(container_cpu_user_seconds_total{image!=""}[5m]) * 100)

CPU Usage per container :

(* 待驗證)rate(container_cpu_user_seconds_total{image!=""}[5m]) * 100

 

4.容器內存

所有容器:

container_memory_rss{name=~".+"}

## container_memory_rss : Size of RSS in bytes

## RSS : RSS- Resident Set Size 實際使用物理內存(包含共享庫佔用的內存)

## name = ~".+" : 根據名稱查詢,也可根據ID查詢,即 id=~".+"

 

所有容器總和:

sum(container_memory_rss{name=~".+"})

 

所有容器當前內存使用:

container_memory_usage_bytes{name=~".+"}

## container_memory_usage_bytes : Current memory usage in bytes.

 

所有容器當前內存使用總和:

sum(container_memory_usage_bytes{name=~".+"})

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章