Prometheus: Apache Exporter – Install and Config – Ubuntu, CentOS

What is Apache Exporter? Apache Exporter is a Prometheus exporter for Apache metrics that exports Apache server status reports generated by mod_status with the URL of

In this article I’ll show how create Apache server status page, how to build Apache Exporter with go get and how to configure it using a systemd service manager on Ubuntu and CentOS.

Cool Tip: Install Node Exporter on Ubuntu and CentOS! Read More →

Enable Apache Server Status Page

To enable server-status reports, create the following configuration file:

# Ubuntu
$ sudo vi /etc/apache2/conf-available/server-status.conf

# CentOS
$ sudo vi /etc/httpd/conf.d/server-status.conf

With this contents:

ExtendedStatus on
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from

Restart Apache:

# Ubuntu
$ cd /etc/apache2/conf-enabled
$ sudo ln -s ../conf-available/server-status.conf server-status.conf && cd
$ sudo systemctl restart apache2

# CentOS
$ sudo systemctl restart httpd

Check the server-status page:

$ curl

Install Go and Git

We need Go to compile apache_exporter from sources.

Cool Tip: GoLang Tutorial – Install Go on MacOS, Ubuntu, CentOS! Read More →

Download and install the latest version of Go for your platform from the official download page (the current version of Go is 1.11):

$ curl -O
$ sudo tar -C /usr/local -xvzf go1.11.linux-amd64.tar.gz
$ echo "export GOPATH=$HOME/go" >> ~/.profile
$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
$ source ~/.profile
$ go version
go version go1.11 linux/amd64

We also need git package to download sources of apache_exporter from GitHub using go get command, otherwise we may get the error as follows:

go: missing Git command. See
package exec: “git”: executable file not found in $PATH

Install Git:

# Ubuntu
$ sudo apt install git

# CentOS
$ sudo yum install git

Apache Exporter: Install and Config

Create unprivileged apache_exporter user:

$ sudo useradd apache_exporter -s /sbin/nologin

Download and compile Apache Exporter:

$ go get -v
$ sudo cp ~/go/bin/apache_exporter /usr/sbin/

Create a systemd service file /etc/systemd/system/apache_exporter.service:

Description=Apache Exporter

ExecStart=/usr/sbin/apache_exporter $OPTIONS


Create a sysconfig file:

$ sudo mkdir -p /etc/sysconfig
$ sudo touch /etc/sysconfig/apache_exporter

Use this file to define options to provide, for example:


To check the all available options, run:

$ /usr/sbin/apache_exporter --help

Reload systemd configuration and configure apache_exporter to auto-start on system boot:

$ sudo systemctl daemon-reload
$ sudo systemctl enable apache_exporter

Start the apache_exporter service:

$ sudo systemctl start apache_exporter

Once the Apache Exporter is installed, verify that metrics are being exported:

$ curl http://localhost:9117/metrics

Add Apache Exporter Target to Prometheus

Cool Tip: Install Prometheus using Docker on Ubuntu and CentOS! Read More →

Now all that’s left is to tell Prometheus server about the new target.

This needs to be done in the Prometheus config, as Apache Exporter just exposes metrics and Prometheus pulls them from the targets it knows about.

Open your Prometheus config file prometheus.yml, and add your machine to the scrape_configs section as follows:

  - job_name: 'apache'
      - targets: ['$NODE_IP:9117']

Reload the Prometheus config, and you should now be able to access Apache metrics through Prometheus!

Was it useful? Share this post with the world!

7 Replies to “Prometheus: Apache Exporter – Install and Config – Ubuntu, CentOS”

  1. The configuration is wrong

    OPTIONS="-scrape_uri string ''"


    OPTIONS="-scrape_uri  ''"

    without String

      1. Felipe Gonzalez says: Reply

        Actually you don’t need to use this configuration if inside apache configuration you define: Allow from localhost # instead of 🙂

    1. OPTIONS=”–scrape_uri=’'”

  2. is there way to configure what metrics are being collected ?

    1. We need to build our own Custom Exporter using Grok Exporter, which basically reads from access.log and expose metrics that way.

  3. TO configure our own metrics we need to use Custom Exporter, using grok exporter. But as much as possible try to avoid this

Leave a Reply