2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
URL de téléchargement
https://github.com/prometheus/prometheus/releases
Sélectionnez la version requise
wget https://github.com/prometheus/prometheus/releases/download/v2.53.0/prometheus-2.53.0.linux-amd64.tar.gz
groupadd prometheus
useradd -g prometheus -m -s /sbin/nologin prometheus
tar -zxvf prometheus-2.53.0.linux-amd64.tar.gz
mv prometheus-2.53.0.linux-amd64 /usr/local/prometheus
sed -i 's/localhost/ 172.25.0.166/g' /usr/local/prometheus/prometheus.yml
vim /etc/profile
export PROMETHEUS_HOME=/usr/local/prometheus
PATH=$PATH:$PROMETHEUS_HOME
export PATH
Recharger le fichier de variables d'environnement système
source /etc/profile
prometheus --version
mkdir /usr/local/prometheus/data/
chown -R prometheus.prometheus /usr/local/prometheus
cd /usr/local/prometheus/
./promtool check config prometheus.yml
cat <<EOF > /usr/lib/systemd/system/prometheus.service
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data/ --web.enable-lifecycle --storage.tsdb.retention.time=30d
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
Remarques sur les paramètres :
systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus && systemctl enable prometheus
ss -lnput | grep 9090
tcp LISTEN 0 512 *:9090 *:* users:(("prometheus",pid=20863,fd=7))
http://172.25.0.166:9090/metrics
URL de téléchargement
https://github.com/prometheus/node_exporter/releases
Téléchargez la version requise
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.1/node_exporter-1.8.1.linux-amd64.tar.gz
groupadd prometheus
useradd -g prometheus -m -s /sbin/nologin prometheus
tar -zxvf node_exporter-1.8.1.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv node_exporter-1.8.1.linux-amd64 node_exporter
chown -R prometheus.prometheus /usr/local/node_exporter
vim /etc/profile
export NODE_EXPORTER=/usr/local/node_exporter
export PATH=$PATH:$NODE_EXPORTER
export PATH
Recharger le fichier de variables d'environnement système
source /etc/profile
cat > /usr/lib/systemd/system/node_exporter.service <<EOF
[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable node_exporter && systemctl start node_exporter
systemctl status node_exporter
ss -lnput | grep 9100
tcp LISTEN 0 512 *:9100 *:* users:(("node_exporter",pid=21904,fd=3))
Modifier le fichier de configuration Prometheus
vim /usr/local/prometheus/prometheus.yml
scrape_configs:
...
- job_name: 'Linux Node' # 添加监控项的名字
static_configs:
- targets: ['172.25.0.166:9100'] # 监控主机的ip地址和端口号
Redémarrez le service Prometheus
systemctl restart prometheus
http://172.25.0.166:9090/targets?search=&scrapePool=Linux+Node
http://172.25.0.166:9100/metrics
URL de téléchargement
https://grafana.com/grafana/download
Téléchargez la version requise
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-11.1.0-1.x86_64.rpm
rpm -ivh grafana-enterprise-11.1.0-1.x86_64.rpm
systemctl daemon-reload
systemctl enable grafana-server && systemctl start grafana-server
vim /etc/grafana/grafana.ini
[users]
# 设置默认语言为中文
default_language = zh-Hans
Redémarrer le service
systemctl restart grafana-server
https://grafana.com/grafana/dashboards/15172-node-exporter-for-prometheus-dashboard-based-on-11074/
grafana-cli plugins install grafana-piechart-panel
ou
tar -xvf grafana-piechart-panel.tar.gz
mv grafana-piechart-panel /var/lib/grafana/plugins/grafana-piechart-panel
https://prometheus.io/
https://blog.csdn.net/heian_99/article/details/126989356
https://www.cnblogs.com/saneri/p/14667301.html
https://blog.csdn.net/qq_31725371/article/details/114697770