美文网首页
prometheus-node_exporter安装部署

prometheus-node_exporter安装部署

作者: 会倒立的香飘飘 | 来源:发表于2021-03-23 10:17 被阅读0次

一,安装node_exporter

node_exporter是监控服务器CPU、内存、磁盘、I/O等信息,首先需要安装node_exporter。node_exporter的作用是用于机器系统数据收集。

1,官网下载地址
https://prometheus.io/download/#node_exporter
2,解压二进制包
tar -xf node_exporter-1.1.2.linux-amd64.tar.gz 
mv node_exporter-1.1.2.linux-amd64 /usr/local/node_exporter
3,创建用户
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/node_exporter
5,systemd管理服务
cat > /etc/systemd/system/node_exporter.service << EOF
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
6,启动node_exporter
systemctl daemon-reload 
systemctl start node_exporter.service 
systemctl enable node_exporter.service 

查看状态


image.png
[root@node_exporter ~]# ps -ef |grep node_exporter
prometh+  17830      1  0 09:30 ?        00:00:00 /usr/local/node_exporter/node_exporter
root      17872  17688  0 09:35 pts/0    00:00:00 grep --color=auto node_exporter
[root@node_exporter ~]# ss -lntup |grep 9100
tcp    LISTEN     0      128      :::9100                 :::*                   users:(("node_exporter",pid=17830,fd=3))

node_exporter默认地址是IP:9100/metrics可以通过curl命令抓取相信的数据

[root@node_exporter ~]# curl 10.0.0.21:9100/metrics
# HELP node_xfs_write_calls_total Number of write(2) system calls made to files in a filesystem.
# TYPE node_xfs_write_calls_total counter
node_xfs_write_calls_total{device="dm-0"} 17181
node_xfs_write_calls_total{device="sda1"} 209
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.06
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1024
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 9
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.499136e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.61646305842e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.32950528e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
# HELP promhttp_metric_handler_errors_total Total number of internal errors encountered by the promhttp metric handler.
# TYPE promhttp_metric_handler_errors_total counter
promhttp_metric_handler_errors_total{cause="encoding"} 0
promhttp_metric_handler_errors_total{cause="gathering"} 0
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 1
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
#截取了一小部分
7,配置prometheus.yaml
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','node_exporter:9100']

image.png
#重启服务
[root@prometheus ~]# systemctl restart prometheus.service 

8,web界面访问
image.png

相关文章

网友评论

      本文标题:prometheus-node_exporter安装部署

      本文链接:https://www.haomeiwen.com/subject/qxixhltx.html