zoukankan      html  css  js  c++  java
  • Prometheus针对k8s的cadvisor监控指标

    1.cAvisor简介:
    cAdvisor是Google开源的容器资源监控和性能分析工具,它是专门为容器而生,在Kubernetes中,我们不需要单独去安装,cAdvisor作为kubelet内置的一部分程序可以直接使用,也就是我们可以直接使用cadvisor采集数据,可以采集到和容器运行相关的所有指标,单独安装cAdvisor时的数据路径为/api/v1/nodes/[节点名称]/proxy/metrics/cadvisor,如果cadvisor集成到kubelet,采集数据的路径是https://127.0.0.1:10250/metrics/cadvisor

    2、cadvisor中获取到的典型监控指标如下

    指标名称 类型 含义
    container_cpu_load_average_10s gauge            过去10秒容器CPU的平均负载
    container_cpu_usage_seconds_total counter  容器在每个CPU内核上的累积占用时间 (单位:秒)
    container_cpu_system_seconds_total counter  System CPU累积占用时间(单位:秒)
    container_cpu_user_seconds_total counter  User CPU累积占用时间(单位:秒)
    container_fs_usage_bytes gauge            容器中文件系统的使用量(单位:字节)
    container_fs_limit_bytes gauge            容器可以使用的文件系统总量(单位:字节)
    container_fs_reads_bytes_total counter  容器累积读取数据的总量(单位:字节)
    container_fs_writes_bytes_total counter  容器累积写入数据的总量(单位:字节)
    container_memory_max_usage_bytes gauge            容器的最大内存使用量(单位:字节)
    container_memory_usage_bytes gauge            容器当前的内存使用量(单位:字节)
    container_spec_memory_limit_bytes gauge            容器的内存使用量限制
    machine_memory_bytes  gauge            当前主机的内存总量
    container_network_receive_bytes_total counter  容器网络累积接收数据总量(单位:字节)
    container_network_transmit_bytes_total counter 

    容器网络累积传输数据总量(单位:字节)

         
         
         
         
         

    3.当能够正常采集到cAdvisor的样本数据后,可以通过以下表达式计算容器的CPU使用率:

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

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

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

    (4)sum(rate(container_network_transmit_bytes_total{image!=""}[1m])) without (interface)
    容器网络传输量 字节/秒

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

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

    4.cadvisor 常用容器监控指标
    (1)网络流量
    sum(rate(container_network_receive_bytes_total{name=~".+"}[1m])) by (name)
    ##容器网络接收的字节数(1分钟内),根据名称查询 name=~".+"

    sum(rate(container_network_transmit_bytes_total{name=~".+"}[1m])) by (name)
    ##容器网络传输的字节数(1分钟内),根据名称查询 name=~".+"


    (2)容器 CPU相关
    sum(rate(container_cpu_system_seconds_total[1m]))
    ###所用容器system cpu的累计使用时间(1min钟内)

    sum(irate(container_cpu_system_seconds_total{image!=""}[1m])) without (cpu)
    ###每个容器system cpu的使用时间(1min钟内)


    sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100
    #每个容器的cpu使用率


    sum(sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100)
    #总容器的cpu使用率

  • 相关阅读:
    STL读书笔记
    时间复杂度
    GDB十分钟教程
    lua函数随记
    svn提交时强制添加注释
    按位与、或、异或等运算方法
    mongodb常用语句
    STL容器的基本特性和特征
    C++:模板
    Vector 特性
  • 原文地址:https://www.cnblogs.com/gavin11/p/12612082.html
Copyright © 2011-2022 走看看