zoukankan      html  css  js  c++  java
  • 容器promQL语法之CPU指标

     k8s通过request(下限)和limit(上限)限制容器的CPU和内存的使用范围

    在容器运行的过程中需要实时监控容器对cpu的使用情况

    1、 容器用户态占用CPU的时间总和

    container_cpu_user_seconds_total

    2、 容器内核态占用CPU的时间总和

    container_cpu_system_seconds_total
    

     3、 container_cpu_user_seconds_total与container_cpu_system_seconds_total的总和,代表容器占用CPU的总和

    container_cpu_usage_seconds_total
    

     4、 由于这些指标都是计数器类型的,所以可以通过rate函数获取样本变化率

    获取5min的样本变化率的表达式如下:

    sum (rate(container_cpu_usage_seconds_total[5m])) by (container_name)
    

     5、容器的每次CPU消耗超过设置的上限后,都会以累加的方式得到记录

    在 container_cpu_cfs_throttled_seconds_total 指标中可以通过rate函数获取变化率

    sum (rate(container_cpu_cfs_throttled_seconds_total[5m])) by (container_name)
    

     如果容器的这个指标过高,则需要调整CPU的上限或者查看程序是有死循环等问题

    6、 查询容器相关的 数据:查询所有POD的1min内CPU使用情况,用到的数据指标是<container_cpu_usage_seconds_total>

    由于查询到的数据都是容器相关的,所以最好按照Pod聚合,对应的promQL语句如下

    sum by (pod) ( rate(container_cpu_usage_seconds_total{image!="",pod!=""}[1m]))
  • 相关阅读:
    C++ Primer Plus(三)
    C++ Primer Plus(二)
    C++ Primer Plus(一)
    C Primer Plus(三)
    C++ 函数重载,函数模板和函数模板重载,选择哪一个?
    Spring IoC 公共注解详解
    Spring IoC @Autowired 注解详解
    Spring IoC 容器的扩展
    Spring IoC bean 的初始化
    Spring IoC 属性赋值阶段
  • 原文地址:https://www.cnblogs.com/suyj/p/15621184.html
Copyright © 2011-2022 走看看