原创

prometheus监控linux系统-node_exporter

温馨提示:
本文最后更新于 2022年06月07日,已超过 355 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

prometheus安装教程 已经了解到了如何安装prometheus

node_exporter安装

node_exporter可以采集主机信息(服务器信息)

下载地址:

https://github.com/prometheus/node_exporter/releases

wget  https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
tar -zvxf node_exporter-1.3.1.linux-amd64.tar.gz
cd node_exporter-1.3.1.linux-amd64/

启动

[root@localhost node_exporter-1.3.1.linux-amd64]# ./node_exporter 
ts=2022-06-07T05:47:29.871Z caller=node_exporter.go:182 level=info msg="Starting node_exporter" version="(version=1.3.1, branch=HEAD, revision=a2321e7b940ddcff26873612bccdf7cd4c42b6b6)"
ts=2022-06-07T05:47:29.871Z caller=node_exporter.go:183 level=info msg="Build context" build_context="(go=go1.17.3, user=root@243aafa5525c, date=20211205-11:09:49)"
ts=2022-06-07T05:47:29.871Z caller=node_exporter.go:185 level=warn msg="Node Exporter is running as root user. This exporter is designed to run as unpriviledged user, root is not required."
ts=2022-06-07T05:47:29.871Z caller=filesystem_common.go:111 level=info collector=filesystem msg="Parsed flag --collector.filesystem.mount-points-exclude" flag=^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+)($|/)
ts=2022-06-07T05:47:29.871Z caller=filesystem_common.go:113 level=info collector=filesystem msg="Parsed flag --collector.filesystem.fs-types-exclude" flag=^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:108 level=info msg="Enabled collectors"
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=arp
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=bcache
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=bonding
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=btrfs
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=conntrack
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=cpu
ts=2022-06-07T05:47:29.872Z caller=node_exporter.go:115 level=info collector=cpufreq

设置为系统服务

 vi /etc/systemd/system/node_exporter.service
[Unit]
Description=node-exporter

[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/local/node_exporter/node_exporter

[Install]
WantedBy=multi-user.target

启动:

 systemctl start node_exporter
 systemctl status node_exporter
 systemctl enable node_exporter

配置prometheus

在prometheus.yml上新增监控节点:

  - job_name: 'my-home-linux'
    static_configs:
      - targets:
          - 'localhost:9100'

重启prometheus,即可看到服务器信息

正文到此结束
本文目录