当前位置:网站首页>Calculate CPU utilization [Prometheus]
Calculate CPU utilization [Prometheus]
2022-07-24 09:40:00 【liuyunshengsir】
1.CPU Usage formula
We know
CPU The usage rate of = ( All non idle states CPU Total usage time )/( All States CPU The sum of time )
By the following formula :
CPU Total usage time = All non idle states CPU Total usage time + All idle states CPU Total usage time
obtain :
CPU The usage rate of = 1 - ( All idle states CPU Total usage time )/( All States CPU The sum of time )
2.prometheus Calculation CPU Usage rate
CPU Total usage time :node_cpu_seconds_total, It means all kinds of occupied time .
2.1 CPU Use your time 5m Incremental value
5m Incremental value = Current sampling point value - 5m Previous sampling point value
Input : increase(node_cpu_seconds_total[5m])
2.2 CPU Free time 5m Incremental value
node_cpu_seconds_total Sample data of , It is based on the implementation sequence key/vlue Format , and key yes "mode" The sampling is recorded CPU The time of that state (user、sys、idle etc. )
Input :increase(node_cpu_seconds_total{mode=“idle”}[5m])
2.3 Polymerized multicore CPU Free time 5m Incremental value
By sampling data , You can see CPU Free time 5m Incremental value , Is each cpu And are taken as a sampling value , And every virtual machine \ The physical machine , Most of them are multicore , So we need to aggregate the idle time of all cores .
Input :sum(increase(node_cpu_seconds_total{mode=“idle”}[5m]))
It can be seen from the results ,sum The function is to put all CPU Audit time wants to add , No aggregation by host , Therefore, it is necessary to introduce =by (instance)= function , It will bring sum The summed values are split in the specified way ,instance It represents the machine name . If you don't write by (instance) You need to be in {} Which instance of the data is required .
Input :sum(increase(node_cpu_seconds_total{mode=“idle”}[5m])) by (instance)
2.4 Aggregate single machine multicore CPU Total usage time 5m Incremental value
Input :sum(increase(node_cpu_seconds_total[5m])) by (instance)
2.5 Calculate the average 5 minute CPU Usage rate
Input :1- sum(increase(node_cpu_seconds_total{mode=“idle”}[5m])) by (instance)/sum(increase(node_cpu_seconds_total[5m])) by (instance)
边栏推荐
- Vim: use tags file to extend the automatic code completion function of YCM for the third-party library of C language
- Hands on deep learning (VII) -- bounding box and anchor box
- Cess test online line! The first decentralized storage network to provide multiple application scenarios
- Development history of the first commercial humanoid biped robot in China
- Tiflash source code reading (V) deltatree storage engine design and implementation analysis - Part 2
- Friends come to interview a unicorn company in Beijing at leisure. The interview question is priced at 25K
- MySQL Basics (I) -- SQL Basics
- Firewall off and on command
- 分类与回归的区别
- [don't bother with intensive learning] video notes (III) 1. What is SARS?
猜你喜欢

Open source summer interview | learn with problems, Apache dolphin scheduler, Wang Fuzheng

代码随想录笔记_链表_25K个一组翻转链表

Spark Learning: a form of association in a distributed environment?

唐宇迪opencv-背景建模

Leetcode94 detailed explanation of middle order traversal of binary tree

Detailed explanation of the whole process of R & D demand splitting | agile practice

Android system security - 5.3-apk V2 signature introduction
![[example] v-contextmenu right click menu component](/img/d7/9287b24a6d9ada01a7f258dd34f0f8.jpg)
[example] v-contextmenu right click menu component
![[don't bother to strengthen learning] video notes (III) 3. SARS (lambda)](/img/3b/981bd564a5855a317ccdd4800871ce.png)
[don't bother to strengthen learning] video notes (III) 3. SARS (lambda)

DP longest common subsequence detailed version (LCS)
随机推荐
Vim: use tags file to extend the automatic code completion function of YCM for the third-party library of C language
07 Jason module
Write a simple memo using localstorage
Detailed sequence traversal of leetcode102 binary tree
Es document CRUD
Detailed explanation of the whole process of R & D demand splitting | agile practice
Understanding of magnetic parameters in Hall sensors
获取所有股票历史行情数据
[200 opencv routines] 236. Principal component analysis of feature extraction (openCV)
[don't bother to strengthen learning] video notes (IV) 1. What is dqn?
[note] what is kernel / user space? Let's start with how the CPU runs the program
华为无线设备安全策略配置命令
Cess test online line! The first decentralized storage network to provide multiple application scenarios
Getting started with web security - open source firewall pfsense installation configuration
Huawei wireless device security policy configuration command
[assembly language practice] (II). Write a program to calculate the value of expression w=v- (x+y+z-51) (including code and process screenshots)
SQL server2012 installation method details [easy to understand]
Financial digital transformation
[Luogu p5410] [template] extend KMP (Z function) (string)
[don't bother to strengthen learning] video notes (III) 2. SARS learning realizes maze walking