1、在prometheus的配置文件prometheus.yml中添加node_exporter组件(一定要注意空格,不然会报错的)

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
  # 采集node exporter监控数据
  - job_name: 'node'
    static_configs:
 - targets: ['localhost:9100']

或者直接加到prometheus后面,这样的话之后加入的组件不好区分,推荐上面的配置。

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090','localhost:9100']

在这里插入图片描述

2、重启prometheus

./Prometheus  #点击刷新页面

在这里插入图片描述
注意:出现黄色的警告提示说明你的系统时间没有同步,解决方式如下(还有其方式,自己百度):

# yum -y install ntp
# systemctl enable ntpd
# ntpdate time1.aliyun.com

在这里插入图片描述
在这里插入图片描述

3、promQL测试收集到的数据

increase(node_cpu_seconds_total{mode='idle'}[1m])  #cpu空闲量

在这里插入图片描述

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐