Prometheus监控工具安装部署

下载linux安装包

https://prometheus.io/download/

image.png

  • 创建并解压
tar -zxvf prometheus-2.25.0.linux-amd64.tar.gz -C ./prometheus
  • 启动并监听端口
/bhp/prometheus/prometheus --config.file=/bhp/prometheus/prometheus.yml --web.listen-address=:26690

配置服务

[Unit]
Description=https://prometheus.io

[Service]
Restart=on-failure
ExecStart=/bhp/prometheus/prometheus --config.file=/bhp/prometheus/prometheus.yml --web.listen-address=":26690"

[Install]
WantedBy=multi-user.target

启动服务

# 开机启动
systemctl enable prometheus.serivce
systemctl start prometheus.service
systemctl status prometheus

使用Node-Exporter收集节点数据

image.png
 mkdir node_exporter
tar -zxvf node_exporter-1.1.2.linux-amd64.tar.gz -C ./node_exporter/
/bhp/node_exporter/node_exporter --web.listen-address=":9100"

配置服务

vim  /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target
 
[Service]
Restart=on-failure
# 启动脚本
ExecStart=/bhp/node_exporter/node_exporter  --web.listen-address=":26691"

[Install]
WantedBy=multi-user.target

启动node_exporter服务

# 配置开机启动
systemctl enable node_exporter
 # 启动
systemctl start node_exporter
systemctl status node_exporter

Prometheus收集Node_Exporter监控数据

vim /bhp/prometheus/prometheus.yml

prometheus.yml新增以下内容,其中localhost更改为ip地址或者域名

  - job_name: 'node'

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

    static_configs:
    - targets: ['localhost:26691']

使用Grafana创建可视化Dashboard

  • 安装
https://grafana.com/grafana/download
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容