扩大
缩小

prometheus学习系列三:node_exporter安装部署

node_exporter简介

node_exporter安装部署

[root@node00 ~]# cd /usr/src/
[root@node00 src]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
[root@node00 src]# mkdir /usr/local/exporter -pv 
mkdir: created directory ‘/usr/local/exporter’
[root@node00 src]# tar xf node_exporter-0.18.1.linux-amd64.tar.gz  -C /usr/local/exporter/
[root@node00 src]# cd /usr/local/exporter/
[root@node00 exporter]# ls
node_exporter-0.18.1.linux-amd64
[root@node00 exporter]# ln -s node_exporter-0.18.1.linux-amd64/ node_exporter

node_exporter启动

[root@node00 node_exporter]# ./node_exporter 
INFO[0000] Starting node_exporter (version=0.18.1, branch=HEAD, revision=3db77732e925c08f675d7404a8c46466b2ece83e)  source="node_exporter.go:156"
INFO[0000] Build context (go=go1.12.5, user=root@b50852a1acba, date=20190604-16:41:18)  source="node_exporter.go:157"
INFO[0000] Enabled collectors:                           source="node_exporter.go:97"
# 中间输出省略
INFO[0000] Listening on :9100                            source="node_exporter.go:170"

测试node_exporter

[root@node00 ~]# curl 127.0.0.1:9100/metrics
# 这里可以看到node_exporter暴露出来的数据。

 配置node_exporter开机自启

[root@node00 system]# cd /usr/lib/systemd/system
# 准备systemd文件 [root@node00 systemd]#
cat node_exporter.service [Unit] Description=node_exporter After=network.target [Service] User=prometheus Group=prometheus ExecStart=/usr/local/exporter/node_exporter/node_exporter\ --web.listen-address=:20001\ --collector.systemd\ --collector.systemd.unit-whitelist=(sshd|nginx).service\ --collector.processes\ --collector.tcpstat\ --collector.supervisord [Install] WantedBy=multi-user.target
# 启动 [root@node00 exporter]# systemctl restart node_exporter
# 查看状态 [root@node00 exporter]# systemctl status node_exporter ● node_exporter.service
- node_exporter Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2019-09-20 22:43:09 EDT; 5s ago Main PID: 88262 (node_exporter) CGroup: /system.slice/node_exporter.service └─88262 /usr/local/exporter/node_exporter/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(sshd|nginx).service Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - stat" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - systemd" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - textfile" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - time" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - timex" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - uname" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - vmstat" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - xfs" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg=" - zfs" source="node_exporter.go:104" Sep 20 22:43:09 node00 node_exporter[88262]: time="2019-09-20T22:43:09-04:00" level=info msg="Listening on :9100" source="node_exporter.go:170"

# 开机自启
[root@node00 exporter]# systemctl enable node_exporter

配置prometheus采集node信息

修改配置文件

[root@node00 prometheus]# cd /usr/local/prometheus/prometheus
[root@node00 prometheus]# vim prometheus.yml
# 在scrape_configs中加入job node ,最终scrape_configs如下配置
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
  - job_name: "node"
    static_configs:
    - targets: 
      - "192.168.100.10:20001"

[root@node00 prometheus]# systemctl restart prometheus 
[root@node00 prometheus]# systemctl status prometheus

查看集成

样例查询

 

posted on 2019-09-24 16:56  LinuxPanda  阅读(5397)  评论(0编辑  收藏

导航