首页 > 其他 > 详细

Prometheus监控K8S容器 表达式计算

时间:2020-03-08 01:19:48      阅读:542      评论:0      收藏:0      [点我收藏+]

表达式

容器CPU使用率:
sum(irate(container_cpu_usage_seconds_total{image!=""}[1m])) without (cpu)

全部容器的CPU使用率总和:
sum(sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100)

查询容器内存使用量(单位:字节):
container_memory_usage_bytes{image!=""}


所有容器总和:

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



查询容器网络接收量速率(单位:字节/秒):
sum(rate(container_network_receive_bytes_total{image!=""}[1m])) without (interface)

查询容器网络传输量速率(单位:字节/秒):
sum(rate(container_network_transmit_bytes_total{image!=""}[1m])) without (interface)

查询容器文件系统读取速率(单位:字节/秒):
sum(rate(container_fs_reads_bytes_total{image!=""}[1m])) without (device)

查询容器文件系统写入速率(单位:字节/秒):
sum(rate(container_fs_writes_bytes_total{image!=""}[1m])) without (device)

容器入带宽大于50M
sum by (namespace,job,pod_name) (irate(container_network_receive_bytes_total{image!=""}[3m]))  / 1024 /1024 > 50

容器出带宽大于50M
sum by (namespace,job,pod_name) (irate(container_network_transmit_bytes_total{image!=""}[1m]))  / 1024 /1024 > 50

Prometheus基础

1.时间序列是指将同一统计指标的数值按其发生的时间先后顺序排列而成的数列

  1. =:选择正好相等的字符串标签
    !=:选择不相等的字符串标签
    =~:选择匹配正则表达式的标签(或子标签)
    !~:选择不匹配正则表达式的标签(或子标签)

  2. s:seconds
    m:minutes
    h:hours
    d:days
    w:weeks
    y:years

注: [1m]指过去的1分钟内

4.操作符

bool
and
or
unless
on
without : without(label)在结果中移除括号内的标签和值
by : by(label)在结果中只保留括号内的标签和值

Prometheus监控K8S容器 表达式计算

原文:https://www.cnblogs.com/shunzi115/p/12439356.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!