Guides followed:
- https://machineperson.github.io/monitoring/2016/01/04/exporting-apache-metrics-to-prometheus.html
- https://www.shellhacks.com/prometheus-apache-exporter-install-config-ubuntu-centos/
# Guides followed: # https://machineperson.github.io/monitoring/2016/01/04/exporting-apache-metrics-to-prometheus.html # https://www.shellhacks.com/prometheus-apache-exporter-install-config-ubuntu-centos/ # Install the needed packages sudo yum install golang git httpd # Create the needed environment for GOLang mkdir ~/go export GOPATH=$HOME/go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin # Refresh your bash source ~/.bashrc # Create apache_exporter user sudo useradd apache_exporter -s /sbin/nologin # Create Apache Location declare apache_exporter=$(cat <<EOF ExtendedStatus on <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 </Location> EOF ) echo "$apache_exporter" echo -e "$apache_exporter"|sudo tee /etc/httpd/conf.d/server-status.conf # Restart Apache sudo systemctl restart httpd # Validate Page curl http://127.0.0.1/server-status # Install the Apache exporter go get -v github.com/Lusitaniae/apache_exporter # sudo ln -s ~/go/bin/apache_exporter /usr/bin sudo cp ~/go/bin/apache_exporter /usr/sbin/ # Create the service file declare apache_exporter_service=$(cat <<EOF [Unit] Description=Apache Exporter [Service] User=apache_exporter EnvironmentFile=/etc/sysconfig/apache_exporter ExecStart=/usr/sbin/apache_exporter $OPTIONS [Install] WantedBy=multi-user.target EOF ) echo "$apache_exporter_service" echo -e "$apache_exporter_service"|sudo tee /etc/systemd/system/apache_exporter.service # Create sysconfig sudo mkdir -p /etc/sysconfig echo "OPTIONS=\"-scrape_uri='http://127.0.0.1/server-status/?auto'\"" | sudo tee /etc/sysconfig/apache_exporter # OPTIONAL: Get all available options of the apache_exporter # /usr/sbin/apache_exporter --help # Reload the systemd sudo systemctl daemon-reload # Enable the new service sudo systemctl enable apache_exporter.service # Start the new service sudo systemctl start apache_exporter.service # Get status of the new service sudo systemctl status apache_exporter.service # View raw Prometheus metrics curl http://localhost:9117/metrics
Last Updated on August 17, 2024
You must be logged in to post a comment.