01 初识Prometheus -使用Node Exporter采集主机运行数据

在Prometheus的架构设计中,Prometheus Server并不直接服务监控特定的目标,其主要任务负责数据的收集,存储并且对外提供数据查询支持。因此为了能够能够监控到某些东西,如主机的CPU使用率,我们需要使用到Exporter。Prometheus周期性的从Exporter暴露的HTTP服务地址(通常是/metrics)拉取监控样本数据。

这里为了能够采集到主机的运行指标如CPU, 内存,磁盘等信息。我们可以使用Node Exporter

安装Node Exporter

Node Exporter同样采用Golang编写,并且不存在任何的第三方依赖,只需要下载,解压即可运行

可以从https://prometheus.io/download/获取最新的node exporter版本的二进制包。

我下载: node_exporter-1.1.2.linux-amd64.tar.gz

 

> tar -xzf node_exporter-1.1.2.linux-amd64.tar.gz
> mv node_exporter-1.1.2.linux-amd64  node_exporter-1.1.2
> cd node_exporter-1.1.2
> nohup ./node_exporter --web.listen-address=":8080"   & 

访问 node export

http://ip:8080/metrics

初始Node Exporter监控指标

# HELP node_cpu Seconds the cpus spent in each mode.
# TYPE node_cpu counter
node_cpu{cpu="cpu0",mode="idle"} 362812.7890625
# HELP node_load1 1m load average.
# TYPE node_load1 gauge
node_load1 3.0703125
node_boot_time:系统启动时间
node_cpu:系统CPU使用量
nodedisk*:磁盘IO
nodefilesystem*:文件系统用量
node_load1:系统负载
nodememeory*:内存使用量
nodenetwork*:网络带宽
node_time:当前系统时间
go_*:node exporter中go相关指标
process_*:node exporter自身进程相关运行指标

Prometheus Server能够从当前node exporter获取到监控数据

为了能够让Prometheus Server能够从当前node exporter获取到监控数据,这里需要修改Prometheus配置文件。编辑prometheus.yml并在scrape_configs节点下添加以下内容:

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

 重新启动Prometheus Server

进入到Prometheus Server。如果输入“up”并且点击执行按钮以后,可以看到如下结果:

其中“1”表示正常,反之“0”则为异常

扫描二维码关注公众号,回复: 13175061 查看本文章

猜你喜欢

转载自blog.csdn.net/zhuchunyan_aijia/article/details/118056756