在linux节点上安装node exporter随记:修订间差异
来自三线的随记
小无编辑摘要 |
小无编辑摘要 |
||
(未显示同一用户的3个中间版本) | |||
第1行: | 第1行: | ||
== MONITORING LINUX HOST METRICS WITH THE NODE EXPORTER == | ==MONITORING LINUX HOST METRICS WITH THE NODE EXPORTER== | ||
The Prometheus Node Exporter exposes a wide variety of hardware- and kernel-related metrics. | |||
=== | <br /> | ||
===Systemd configure file example=== | |||
[Unit] | [Unit] | ||
Description=node_exporter | Description=node_exporter | ||
第18行: | 第19行: | ||
[Install] | [Install] | ||
WantedBy=multi-user.target | WantedBy=multi-user.target | ||
===binary file download=== | |||
https://github.com/prometheus/node_exporter/releases | |||
<br /> | <br /> | ||
=== | ===official documentation=== | ||
https://github.com/prometheus/node_exporter/releases | https://prometheus.io/docs/guides/node-exporter/ | ||
<br /> | |||
===下載node exporter 二進制文件壓縮包=== | |||
在節點上執行命令下載 | |||
wget "<nowiki>https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz</nowiki>" | |||
<br /> | |||
===解壓壓縮包=== | |||
[root@master sanXian]# tar -xzf node_exporter-1.0.1.linux-amd64.tar.gz | |||
[root@master sanXian]# ls | |||
node_exporter-1.0.1.linux-amd64 node_exporter-1.0.1.linux-amd64.tar.gz | |||
<br /> | |||
===將 node_exporter-1.0.1.linux-amd64 目錄下的 node_exporter 二進制文件複製到 /usr/local/bin 路徑下=== | |||
注意需要給予該二進制文件nobody用戶可執行權限 | |||
[root@master sanXian]# cd node_exporter-1.0.1.linux-amd64/ | |||
[root@master node_exporter-1.0.1.linux-amd64]# ls | |||
LICENSE node_exporter NOTICE | |||
[root@master node_exporter-1.0.1.linux-amd64]# cp node_exporter /usr/local/bin/ | |||
[root@master node_exporter-1.0.1.linux-amd64]# ls -l /usr/local/bin/node_exporter | |||
-rwxr-xr-x. 1 root root 19657731 Oct 22 12:17 /usr/local/bin/node_exporter | |||
<br /> | |||
===直接複製下文全部文字命令並在節點上執行以創建systemd service文件=== | |||
cat <<EOF > /etc/systemd/system/node_exporter.service | |||
[Unit] | |||
Description=node_exporter | |||
After=network.target | |||
[Service] | |||
User=nobody | |||
Group=nobody | |||
Type=simple | |||
ExecStart=/usr/local/bin/node_exporter\\ | |||
--collector.systemd\\ | |||
--collector.processes | |||
[Install] | |||
WantedBy=multi-user.target | |||
EOF | |||
<br /> | |||
===重載系統 systemd 配置=== | |||
執行命令 <code>systemctl daemon-reload</code> | |||
<br /> | |||
===啟動服務並且設置服務自啟=== | |||
執行命令 <code>systemctl enable --now node_exporter</code> | |||
[root@master system]# systemctl enable --now node_exporter | |||
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /etc/systemd/system/node_exporter.service. | |||
<br /> | |||
===查看服務運行狀態=== | |||
執行命令<code>systemctl status node_exporter</code> | |||
能夠得到類似下文的回顯結果 | |||
主要看Active屬性值為<code>active(running)</code>就好了 | |||
[root@master system]# systemctl status node_exporter | |||
● node_exporter.service - node_exporter | |||
Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled) | |||
Active: active (running) since Thu 2020-10-22 14:20:44 CST; 6min ago | |||
Main PID: 27847 (node_exporter) | |||
CGroup: /system.slice/node_exporter.service | |||
└─27847 /usr/local/bin/node_exporter --collector.systemd --collector.processes | |||
<br /> | <br /> | ||
===測試接口=== | |||
在節點上使用命令<code>curl -I <nowiki>{{節點IP}}</nowiki>:9100/metrics</code>訪問接口 | |||
能夠得到類似下文結果 | |||
[root@master system]# curl -I 192.168.150.166:9100/metrics | |||
HTTP/1.1 200 OK | |||
Content-Type: text/plain; version=0.0.4; charset=utf-8 | |||
Date: Thu, 22 Oct 2020 06:34:49 GMT | |||
或直接使用瀏覽器訪問<code><nowiki>{{節點IP}}</nowiki>:9100/metrics</code>能夠看到相關指標信息則為正常<br /> | |||
[[分类:Linux]] | [[分类:Linux]] | ||
[[分类:Prometheus]] | [[分类:Prometheus]] | ||
{{DEFAULTSORT:node_exporter随记}} | {{DEFAULTSORT:node_exporter随记}} |
2020年10月23日 (五) 15:30的最新版本
MONITORING LINUX HOST METRICS WITH THE NODE EXPORTER
The Prometheus Node Exporter exposes a wide variety of hardware- and kernel-related metrics.
Systemd configure file example
[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
binary file download
https://github.com/prometheus/node_exporter/releases
official documentation
https://prometheus.io/docs/guides/node-exporter/
下載node exporter 二進制文件壓縮包
在節點上執行命令下載
wget "https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz"
解壓壓縮包
[root@master sanXian]# tar -xzf node_exporter-1.0.1.linux-amd64.tar.gz [root@master sanXian]# ls node_exporter-1.0.1.linux-amd64 node_exporter-1.0.1.linux-amd64.tar.gz
將 node_exporter-1.0.1.linux-amd64 目錄下的 node_exporter 二進制文件複製到 /usr/local/bin 路徑下
注意需要給予該二進制文件nobody用戶可執行權限
[root@master sanXian]# cd node_exporter-1.0.1.linux-amd64/ [root@master node_exporter-1.0.1.linux-amd64]# ls LICENSE node_exporter NOTICE [root@master node_exporter-1.0.1.linux-amd64]# cp node_exporter /usr/local/bin/ [root@master node_exporter-1.0.1.linux-amd64]# ls -l /usr/local/bin/node_exporter -rwxr-xr-x. 1 root root 19657731 Oct 22 12:17 /usr/local/bin/node_exporter
直接複製下文全部文字命令並在節點上執行以創建systemd service文件
cat <<EOF > /etc/systemd/system/node_exporter.service [Unit] Description=node_exporter After=network.target [Service] User=nobody Group=nobody Type=simple ExecStart=/usr/local/bin/node_exporter\\ --collector.systemd\\ --collector.processes [Install] WantedBy=multi-user.target EOF
重載系統 systemd 配置
執行命令 systemctl daemon-reload
啟動服務並且設置服務自啟
執行命令 systemctl enable --now node_exporter
[root@master system]# systemctl enable --now node_exporter Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /etc/systemd/system/node_exporter.service.
查看服務運行狀態
執行命令systemctl status node_exporter
能夠得到類似下文的回顯結果
主要看Active屬性值為active(running)
就好了
[root@master system]# systemctl status node_exporter ● node_exporter.service - node_exporter Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2020-10-22 14:20:44 CST; 6min ago Main PID: 27847 (node_exporter) CGroup: /system.slice/node_exporter.service └─27847 /usr/local/bin/node_exporter --collector.systemd --collector.processes
測試接口
在節點上使用命令curl -I {{節點IP}}:9100/metrics
訪問接口
能夠得到類似下文結果
[root@master system]# curl -I 192.168.150.166:9100/metrics HTTP/1.1 200 OK Content-Type: text/plain; version=0.0.4; charset=utf-8 Date: Thu, 22 Oct 2020 06:34:49 GMT
或直接使用瀏覽器訪問{{節點IP}}:9100/metrics
能夠看到相關指標信息則為正常