mise a jour
This commit is contained in:
parent
6604b6d123
commit
31f2628538
@ -18,13 +18,16 @@ sudo systemctl status apache2
|
||||
Prometheus ne peut pas lire directement les métriques Apache. On utilise apache_exporter.
|
||||
|
||||
2.1 Télécharger apache_exporter
|
||||
|
||||
cd /opt
|
||||
sudo wget https://github.com/Lusitaniae/apache_exporter/releases/download/v1.0.10/apache_exporter-1.0.10.linux-amd64.tar.gz
|
||||
sudo tar -xvf apache_exporter-1.0.10.linux-amd64.tar.gz
|
||||
sudo mv apache_exporter-1.0.10.linux-amd64/apache_exporter /usr/local/bin/
|
||||
|
||||
2.2 Créer un service systemd pour apache_exporter
|
||||
|
||||
sudo nano /etc/systemd/system/apache_exporter.service
|
||||
------------->
|
||||
[Unit]
|
||||
Description=Prometheus Apache Exporter
|
||||
After=network.target
|
||||
@ -35,22 +38,22 @@ ExecStart=/usr/local/bin/apache_exporter --scrape_uri="http://localhost/server-s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
------------->
|
||||
|
||||
2.3 Activer le module status d’Apache
|
||||
|
||||
sudo a2enmod status
|
||||
sudo systemctl restart apache2
|
||||
|
||||
2.4 Démarrer apache_exporter
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable apache_exporter
|
||||
sudo systemctl start apache_exporter
|
||||
sudo systemctl status apache_exporter
|
||||
|
||||
✅ À ce stade, Prometheus pourra scrapper les métriques Apache sur le port par défaut 9117 :
|
||||
|
||||
http://<IP_MACHINE2>:9117/metrics//vérifier ça sur le site prometheus
|
||||
|
||||
Étape 4 : Collecter les logs Apache via Loki + Promtail
|
||||
|
||||
4.1 Installer Promtail sur la machine supervisée
|
||||
|
||||
Si Promtail n’est pas encore installé, tu peux le télécharger depuis Grafana :
|
||||
@ -62,10 +65,10 @@ sudo mv promtail-linux-amd64 /usr/local/bin/promtail
|
||||
sudo chmod +x /usr/local/bin/promtail
|
||||
|
||||
4.2 Créer un fichier de config pour Promtail
|
||||
|
||||
sudo nano /etc/promtail-config.yaml
|
||||
|
||||
|
||||
Exemple pour Apache :
|
||||
------------->
|
||||
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
@ -93,21 +96,26 @@ scrape_configs:
|
||||
job: apache_error
|
||||
host: apache_vm
|
||||
__path__: /var/log/apache2/error.log
|
||||
|
||||
------------->
|
||||
|
||||
|
||||
4.3 Créer un service systemd pour Promtail
|
||||
sudo nano /etc/systemd/system/promtail.service
|
||||
|
||||
------------->
|
||||
[Unit]
|
||||
Description=Promtail service for Apache logs
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/promtail-config.yml
|
||||
ExecStart=/usr/local/bin/promtail -config.file /etc/promtail-config.yaml
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
------------->
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable promtail
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user