Setup Apache Exporter on Centos

Pada postingan ini kita akan membahas cara untuk install apache_exporteruntuk memonitoring web server. Dengan itu monitoring Apache menjadi jauh lebih mudah dengan Apache Exporter, yang dapat diintegrasikan dengan Prometheus untuk mendapatkan metrics secara real-time. Berikut langkah-langkah instalasi dan konfigurasi di CentOS 7.

Download binary terbaru

Pola link:

https://github.com/Lusitaniae/apache_exporter/releases/download/v{VERSI}/apache_exporter-{VERSI}.linux-amd64.tar.gz

Cek versi rilis:

https://github.com/Lusitaniae/apache_exporter/releases/latest

Eksekusi:

wget https://github.com/Lusitaniae/apache_exporter/releases/download/v1.0.12/apache_exporter-1.0.12.linux-amd64.tar.gz

tar -xzf apache_exporter-1.0.12.linux-amd64.tar.gz
cd apache_exporter-1.0.12.linux-amd64
cp apache_exporter /usr/sbin/

Menambahkan user

useradd apache_exporter -s /sbin/nologin

Membuat folder config

mkdir -p /etc/sysconfig
echo 'OPTIONS="--scrape_uri=http://{IP Server}/server-status/?auto"' | sudo tee /etc/sysconfig/apache_exporter

Buat service

nano /etc/systemd/system/apache_exporter.service

Isi:

[Unit]
Description=Apache Exporter
After=network.target httpd.service

[Service]
User=apache_exporter
EnvironmentFile=/etc/sysconfig/apache_exporter
ExecStart=/usr/sbin/apache_exporter $OPTIONS
Restart=on-failure

[Install]
WantedBy=multi-user.target

Reload dan restart service

systemctl daemon-reload
systemctl enable apache_exporter
systemctl start apache_exporter

Konfigurasi Apache

File:

/etc/httpd/conf.d/server-status.conf

Isi:

ExtendedStatus On

<Location "/server-status">
    SetHandler server-status
    Order deny,allow
    Allow from 10.10.1.0/24 127.0.0.1
#     Require all granted
</Location>

Jika Require all granted aktif, maka endpoint bisa diakses dari mana saja.

Restart Apache

systemctl restart httpd

Konfigurasi Firewall

firewall-cmd --permanent --zone=public --add-port=9117/tcp

reload firewall

firewall-cmd --reload

Uji Coba

untuk uji coba cukup akses metrics dari web browser
http://{ip_server}:9117
nanti akan muncul kondisi server kita, tinggal di kombinasikan dengan prometheus.

selamat mencoba, semoga bermanfaat.