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.
|
Prometheus ne peut pas lire directement les métriques Apache. On utilise apache_exporter.
|
||||||
|
|
||||||
2.1 Télécharger apache_exporter
|
2.1 Télécharger apache_exporter
|
||||||
|
|
||||||
cd /opt
|
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 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 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/
|
sudo mv apache_exporter-1.0.10.linux-amd64/apache_exporter /usr/local/bin/
|
||||||
|
|
||||||
2.2 Créer un service systemd pour apache_exporter
|
2.2 Créer un service systemd pour apache_exporter
|
||||||
|
|
||||||
sudo nano /etc/systemd/system/apache_exporter.service
|
sudo nano /etc/systemd/system/apache_exporter.service
|
||||||
|
------------->
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Prometheus Apache Exporter
|
Description=Prometheus Apache Exporter
|
||||||
After=network.target
|
After=network.target
|
||||||
@ -35,22 +38,22 @@ ExecStart=/usr/local/bin/apache_exporter --scrape_uri="http://localhost/server-s
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
------------->
|
||||||
|
|
||||||
2.3 Activer le module status d’Apache
|
2.3 Activer le module status d’Apache
|
||||||
|
|
||||||
sudo a2enmod status
|
sudo a2enmod status
|
||||||
sudo systemctl restart apache2
|
sudo systemctl restart apache2
|
||||||
|
|
||||||
2.4 Démarrer apache_exporter
|
2.4 Démarrer apache_exporter
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable apache_exporter
|
sudo systemctl enable apache_exporter
|
||||||
sudo systemctl start apache_exporter
|
sudo systemctl start apache_exporter
|
||||||
sudo systemctl status 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
|
Étape 4 : Collecter les logs Apache via Loki + Promtail
|
||||||
|
|
||||||
4.1 Installer Promtail sur la machine supervisée
|
4.1 Installer Promtail sur la machine supervisée
|
||||||
|
|
||||||
Si Promtail n’est pas encore installé, tu peux le télécharger depuis Grafana :
|
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
|
sudo chmod +x /usr/local/bin/promtail
|
||||||
|
|
||||||
4.2 Créer un fichier de config pour Promtail
|
4.2 Créer un fichier de config pour Promtail
|
||||||
|
|
||||||
sudo nano /etc/promtail-config.yaml
|
sudo nano /etc/promtail-config.yaml
|
||||||
|
|
||||||
|
------------->
|
||||||
Exemple pour Apache :
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
http_listen_port: 9080
|
http_listen_port: 9080
|
||||||
@ -93,21 +96,26 @@ scrape_configs:
|
|||||||
job: apache_error
|
job: apache_error
|
||||||
host: apache_vm
|
host: apache_vm
|
||||||
__path__: /var/log/apache2/error.log
|
__path__: /var/log/apache2/error.log
|
||||||
|
|
||||||
|
------------->
|
||||||
|
|
||||||
|
|
||||||
4.3 Créer un service systemd pour Promtail
|
4.3 Créer un service systemd pour Promtail
|
||||||
sudo nano /etc/systemd/system/promtail.service
|
sudo nano /etc/systemd/system/promtail.service
|
||||||
|
|
||||||
|
------------->
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Promtail service for Apache logs
|
Description=Promtail service for Apache logs
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=root
|
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
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
------------->
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable promtail
|
sudo systemctl enable promtail
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user