BlueXIII's Blog

热爱技术,持续学习

0%

Prometheus监控详细步骤

官网

Grafana

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# rpm方式安装
wget https://dl.grafana.com/oss/release/grafana-9.3.2-1.x86_64.rpm
sudo yum install grafana-9.3.2-1.x86_64.rpm
systemctl start grafana-server
systemctl enable grafana-server

# 二进制方式安装
nohup ./grafana-server 2>&1 &

# 登录地址
http://192.168.101.211:3000

# 钉钉推送地址
https://oapi.zingtalk.com/robot/send?access_token=........

# 备份
/var/lib/grafana/grafana.db
/etc/grafana/grafana.ini

Prometheus

1
2
3
4
# 安装Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.41.0/prometheus-2.41.0.linux-amd64.tar.gz
nohup ./prometheus --config.file=prometheus.yml 2>&1 &
open http://192.168.101.211:9090

BlackboxExporter

1
2
3
4
# 安装BlackboxExporter
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.23.0/blackbox_exporter-0.23.0.linux-amd64.tar.gz
nohup ./blackbox_exporter 2>&1 &
open http://192.168.101.211:9115

NodeExporter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 安装NodeExporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
nohup ./node_exporter --web.config.file=config.yml --web.listen-address=:19100 2>&1 &
open http://192.168.101.211:19100

#设置开机自启
cat << EOF >/etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter Monitoring System
Documentation=node_exporter Monitoring System

[Service]
ExecStart=/opt/node_exporter/node_exporter --web.config.file=/opt/node_exporter/config.yml --web.listen-address=:19100

[Install]
WantedBy=multi-user.target
EOF

# 启动
systemctl daemon-reload
systemctl start node_exporter.service
systemctl status node_exporter.service
systemctl enable node_exporter.service

# 可选: 生成密码
yum install httpd-tools -y
htpasswd -nBC 12 '' | tr -d ':\n' # 输入密码

# 可选:配置密码
cat << EOF >/opt/node_exporter/config.yml
basic_auth_users:
prometheus: \$2y\$12\$hj1xMjOs1iH.......
EOF

# 可选: 卸载
ps -ef|grep node_exporter
systemctl stop node_exporter.service
systemctl disable node_exporter.service
systemctl daemon-reload
rm -f /etc/systemd/system/node_exporter.service