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=~".+"})

你可能感兴趣的:(cadvisor)