I&B Monitoring Platform documentation

Apache exporter for Prometheus

Installation of Apache Exporter for Prometheus in production environment consists from following high level steps:

  1. Install exporter;

  2. Configure authentication;

  3. Configure firewall;

  4. Configure service for autostart and restart;

  5. Check access to exporter from I&B monitoring platform.

1. Install Prometheus apache exporter.

  1. Check latest version, available platforms on apache_exporter GitHub page and make necessary changes in variables on next step.

  2. Prepare environment variables to simplify installation and configuration process.

Bash
export EXPORTER_VERSION=1.0.10
export EXPORTER_PLATFORM=linux-amd64
  1. Download exporter.

Bash
wget https://github.com/Lusitaniae/apache_exporter/releases/download/v$EXPORTER_VERSION/apache_exporter-$EXPORTER_VERSION.$EXPORTER_PLATFORM.tar.gz
  1. Create directory /usr/local/bin/apache_exporter and untar exporter into it.

Bash
sudo mkdir -p /usr/local/bin/apache_exporter
sudo tar xvfz apache_exporter-$EXPORTER_VERSION.$EXPORTER_PLATFORM.tar.gz -C /usr/local/bin/apache_exporter --strip-components=1
  1. Create prometheus user. If it already exist - go to step 6.

Fedora (RHEL, CentOS)

Bash
sudo useradd -M -s /sbin/nologin prometheus
  • -M (or --no-create-home): This option prevents the creation of a home directory for the new user;

  • -s /sbin/nologin: This option sets the user's login shell to /sbin/nologin. This effectively prevents the user from interactively logging into the system. While the user won't have a password set, this further ensures they cannot log in.

Debian (Ubuntu)

Bash
sudo useradd -s /sbin/nologin prometheus --no-create-home
  1. Make prometheus user owner of apache_exporter directory.

Bash
sudo chown -hR prometheus:prometheus /usr/local/bin/apache_exporter

2. Configure firewall

Configure firewall on resource

  1. apache exporter uses default port 9117, so allow it in firewall on resource.

Fedora (RHEL, CentOS)

Bash
sudo firewall-cmd --zone=public --add-port=9117/tcp --permanent
sudo systemctl reload firewalld

Check firewall configuration

Bash
sudo firewall-cmd --list-all

You should see in output:

ports: 9117/tcp

Debian (Ubuntu)

Bash
sudo ufw allow 9117

You should see in output:

Bash
Rules updated
Rules updated (v6)

Check firewall configuration

Bash
sudo ufw status

You should see in output:

Bash
To                             Action          From
--                             ------          ----
9117                           ALLOW           Anywhere

its good

3. Configure authentication for exporter

Do the steps described in Exporters configuration → Authentication section.

4. Check configuration

  1. Run apache_exporter in key --scrape_uri="https://your.server.com/server-status?auto" you set ip or domain name of monitoring apache

Bash
/usr/local/bin/apache_exporter/apache_exporter --web.config.file=/usr/local/bin/apache_exporter/web-config.yml --scrape_uri="https://your.server.com/server-status?auto"

In output you should see:

Bash
... msg="TLS is enabled." ...

Check with browser if it is accessible at:

https://resource-hostname-or-ip:9117/metrics

After entering exporter’s user name and password you should see page like this:

Bash
# HELP apache_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which apache_exporter was built, and the goos and goarch for the build.
# TYPE apache_exporter_build_info gauge
apache_exporter_build_info{branch="HEAD",goarch="amd64",goos="linux",goversion="go1.22.12",revision="c4206b529038d79f20f2eeba98a9780c8cb4a2c2",tags="netgo",version="1.0.10"} 1
...

Stop apache exporter with Ctrl-c in terminal where you run it.

Make apache_exporter service for autostart and restart.

Create file with your preferred text editor, for example nano …

Bash
sudo nano /etc/systemd/system/apache_exporter.service

… and paste following text into it.

Bash
[Unit]
Description=apache Exporter

[Service]
User=prometheus
ExecStart=/usr/local/bin/apache_exporter/apache_exporter  --web.config.file=/usr/local/bin/apache_exporter/web-config.yml --scrape_uri="https://your.server.com/server-status?auto"

[Install]
WantedBy=multi-user.target

Save file and exit editor.

Start service …

Bash
sudo systemctl daemon-reload
sudo systemctl start apache_exporter
sudo systemctl enable apache_exporter

… and check

Bash
sudo systemctl status apache_exporter

You should see following output similar to:

image-20250929-063114.png

In case of any problem, you should view log entries for service:

Bash
journalctl -u apache_exporter.service -e

Now apache exporter is ready to accept data and then expose it to Prometheus.