prometheus 安装 node_exporter

1,Ubuntu 16.04安装prometheus

  • prometheus-2.18.1.darwin-amd64.tar.gz
# tar -zxvf prometheus-2.18.1.linux-amd64.tar.gz
  • 设置环境变量
  • vim /root/.bashrc
#prometheus
export PATH=$PATH:/root/prometheus-2.18.1.linux-amd64

2,测试启动

prometheus --config.file=/root/prometheus-2.18.1.linux-amd64/prometheus.yml
  • 0.0.0.0:9090

在这里插入图片描述

2.1,运行前检查配置文件

# ./promtool check config prometheus.yml
Checking prometheus.yml
  SUCCESS: 0 rule files found

2.2,修改prometheus.yml获取监控数据

  • vim prometheus.yml增加job_name
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
  - job_name: 'node'
    static_configs:
    - targets: ['127.0.0.1:9100']

2.3,prometheus开机启动

# vim /lib/systemd/system/prometheus.service
# cat /lib/systemd/system/prometheus.service
[Unit]
Description=prometheus service

[Service]
User=root
ExecStart=/root/prometheus-2.18.1.linux-amd64/prometheus --config.file=/root/prometheus-2.18.1.linux-amd64/prometheus.yml

TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable prometheus.service
Created symlink /etc/systemd/system/multi-user.target.wants/prometheus.service → /lib/systemd/system/prometheus.service.
# systemctl start prometheus.service
# systemctl status prometheus.service

3,node_exporter安装

  • node_exporter-1.0.0.linux-amd64.tar.gz
# tar -zxvf node_exporter-1.0.0.linux-amd64.tar.gz
# cd node_exporter-1.0.0.linux-amd64/
# ./node_exporter
  • 访问ip:9100
    在这里插入图片描述
  • 增加配置prometheus
  • vim prometheus.yml
  - job_name: 'node'
    static_configs:
    #- targets: ['localhost:9090']
    - targets: ['127.0.0.1:9100']

3.1,node_exporter开机启动

# cat /lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter service

[Service]
User=root
ExecStart=/root/node_exporter-1.0.0.linux-amd64/node_exporter

TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable node_exporter.service
# systemctl start node_exporter.service
# systemctl status node_exporter.service

3.1,监控多个主机

  • 192.168.0.3 只运行node_exporter
  • 192.168.0.2 运行有prometheus
  • 配置prometheus.yml
  • targets配置多个IP地址
# cat prometheus.yml
    static_configs:
    - targets: ['localhost:9090']


    # node_exporter
  - job_name: 'node'
    static_configs:
    - targets: ['127.0.0.1:9100','192.168.0.3:9100']

4,prometheus查看targets

在这里插入图片描述

5,数据可视化显示

5.1,Grafana导入面板

在这里插入图片描述

  • id为8919
  • 数据源选择prometheus
    在这里插入图片描述

在这里插入图片描述


参考:

  1. prometheus download
  2. prometheus started
  3. Prometheus ubuntu安装使用
  4. prometheus+grafana 安装配置
  5. node_exporter
  6. Prometheus 实战
  7. Prometheus监控系统 安装与配置详细教程
  8. prometheus-book 使用Node Exporter采集主机数据
  9. Prometheus 配置
  10. Prometheus部署各服务的Node监控
  11. 使用 Grafana + Prometheus + Node-Exporter 监控机器
  12. 1 Node Exporter for Prometheus Dashboard CN v20200530

猜你喜欢

转载自blog.csdn.net/u010953692/article/details/106480966
今日推荐