首页 > 编程语言 >node-exporter和cadvisor收集指标数据

node-exporter和cadvisor收集指标数据

时间:2022-10-07 11:48:32浏览次数:108  
标签:node 容器 exporter container cadvisor bytes prometheus total cpu

收集node-exporter指标数据

  修改prometheus-server配置文件,在scrape_configs配置项下,添加新job

 

root@prometheus:~\ vim /usr/local/prometheus/prometheus.yml
...
  - job_name: "k8s-nodes"
    static_configs:
      - targets: ["192.168.100.4:9100","192.168.100.5:9100"]  #添加node-exporter节点,逗号间隔

  重新加载prometheus-server配置

root@prometheus:~\ curl -X POST http://192.168.100.7:9090/-/reload

 

  访问验证

 

 

node-exporter指标数据说明:

  参考:https://knowledge.zhaoweiguo.com/build/html/cloudnative/prometheus/metrics/kubernetes-cadvisor.html

 

root@prometheus:~\ curl 192.168.100.4:9100/metrics

 

  常见的指标:

  node_boot_time:系统自启动以后的总计时间

  node_cpu:系统CPU使用量

  node_disk*:磁盘IO

   node_filesystem*:系统文件系统用量

  node_load1:系统CPU负载

   node_memeory*:内存使用量

  node_network*:网络带宽指标

  node_time:当前系统时间

  go_*:node exporter中go相关指标

  process_*:node exporter自身进程相关运行指标

 

 

收集cadvisor指标数据

  修改prometheus-server配置文件,在scrape_configs配置项下,添加新job

root@prometheus:~\# vim /usr/local/prometheus/prometheus.yml
...
  - job_name: "k8s-cadvisor"
    static_configs:
      - targets: ["192.168.100.3:8080","192.168.100.4:8080","192.168.100.5:8080"]   #添加容器节点的cadvisor服务地址

 

   重新加载prometheus-server配置

root@prometheus:~\ curl -X POST http://192.168.100.7:9090/-/reload

 

 

  查看prometheus Server节点采集

 

cadvisor指标数据

  https://knowledge.zhaoweiguo.com/build/html/cloudnative/prometheus/metrics/kubernetes-cadvisor.html

指标名称 类型 含义
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 容器网络累积传输数据总量(单位:字节)

 

  当能够正常采集到cAdvisor的样本数据后,可以通过以下表达式计算容器的指标数据:

  (1)容器CPU使用率

    sum(irate(container_cpu_usage_seconds_total{image!=""}[1m])) without (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)

 

 

cadvisor 常用容器监控指标

  (1)网络流量

  容器网络接收的字节数(1分钟内),根据名称查询name=~".+"

    sum(rate(container_network_receive_bytes_total{name=~".+"}[1m])) by (name)

 

  容器网络传输的字节数(1分钟内),根据名称查询 name=~".+"

    sum(rate(container_network_transmit_bytes_total{name=~".+"}[1m])) by (name)

 

 

  (2)容器CPU相关

  所用容器system cpu的累计使用时间(1min钟内)

    sum(rate(container_cpu_system_seconds_total[1m]))

   每个容器system cpu的使用时间(1min钟内)

    sum(irate(container_cpu_system_seconds_total{image!=""}[1m])) without (cpu)

  每个容器的cpu使用率

    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)

 

 

 

 

 

 

 

标签:node,容器,exporter,container,cadvisor,bytes,prometheus,total,cpu
From: https://www.cnblogs.com/punchlinux/p/16759316.html

相关文章

  • Node.js原生开发基础入门
     1.NodeJS编程基础概要2.本地环境搭建与基础入门3.文件操作与模块化概念4.JavaScript模块化开发5.npm包管理       1.NodeJS编程基础概要node.js与J......
  • 前端简史之纵横:Node东出
    引......
  • [转]node.js 支持 ES6 模块化
    需检查是否满足以下条件:1、确保安装了v14.15.1或更高版本的node.js2、命令初始化 package.jsonnpminit-y3、在 package.json的根节点中添加 "type":"modu......
  • Kubernetes--NodePort类型的Service资源
    NodePort类型的Service资源NodePort即节点Port,通常在安装部署Kubernetes集群系统时会预留一个端口范围用于NodePort,默认为30000~32767之间的端口。与ClusterIP类型的可省......
  • 关于 NodeJS 模块化不得不说的坑
    关于NodeJS模块化不得不说的坑本文写于:2022-10-05CJS与ESM的简单介绍面临的问题问题1:如何交叉引入(ESM引入CJS、CJS引入ESM)问题2:ESM必须带上文件扩展名......
  • appendToFile: Failed to replace a bad datanode on the existing pipeline due to n
    报错:appendToFile:Failedtoreplaceabaddatanodeontheexistingpipelineduetonomoregooddatanode原因1:Hadoop默认副本数为3,而我只有2台DataNode,故缺少DataN......
  • 【nodejs开发】nodejs实现socket网络通信
    (本节内容如下:)1、简介在NodeJS中有三种socket:1.TCP,2.UDP,3.Unix域套接字。UDP/datagramsocketsClass:dgram.SocketEvent:'close'Event:'connect'Event:'erro......
  • node-ffi使用指南11
    node-ffi使用指南​​​​​​Githoniel​​码农在​​nodejs​​​/​​elctron​​​中,可以通过​​node-ffi​​​,通过​​ForeignFunctionInterface​​调用动态链接......
  • 运行yarn报错:error C:\liuyan\tools\echarts-5.4.0\node_modules\cwebp-bin: Com
    完成warning和报错信息如下。通过报错信息提示,锁定cwebp-bin,在waring中发现有提示说要更新至7或更高版本。解决方案:在package.json中,将cwebp-bin设置版本为:"cwebp-bin":......
  • NameNode Metadata备份和恢复最佳实践
    温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图。Fayson的github:​​https://github.com/fayson/cdhproject​​提示:代码块部分可......