Skip to content

Instantly share code, notes, and snippets.

@rodrigo-galba
Last active June 14, 2021 14:45
Show Gist options
  • Save rodrigo-galba/f62a18bde1662ed9f2b41e41e6012dd1 to your computer and use it in GitHub Desktop.
Save rodrigo-galba/f62a18bde1662ed9f2b41e41e6012dd1 to your computer and use it in GitHub Desktop.
Apache metrics + Prometheus

Apache metrics + Prometheus

Apache setup

sudo useradd -M -r -s /bin/false apache_exporter
wget https://github.com/Lusitaniae/apache_exporter/releases/download/v0.7.0/apache_exporter-0.7.0.linux-amd64.tar.gz
tar xvfz apache_exporter-0.7.0.linux-amd64.tar.gz
sudo cp apache_exporter-0.7.0.linux-amd64/apache_exporter /usr/local/bin/
sudo chown apache_exporter:apache_exporter /usr/local/bin/apache_exporter
sudo vi /etc/systemd/system/apache_exporter.service

Edit the file using this:

[Unit]
Description=Prometheus Apache Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=apache_exporter
Group=apache_exporter
Type=simple
ExecStart=/usr/local/bin/apache_exporter

[Install]
WantedBy=multi-user.target
sudo systemctl enable apache_exporter
sudo systemctl start apache_exporter
sudo systemctl status apache_exporter
curl localhost:9117/metrics

Prometheus setup

sudo vi /etc/prometheus/prometheus.yml
- job_name: 'Apache Server'
  static_configs:
  - targets: ['localhost:9117']
sudo systemctl restart prometheus
curl http://localhost:9090/api/v1/targets
curl 'http://localhost:9090/api/v1/query?query=apache_exporter_build_info&time=1623019812.603&_=1623019759370'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment