Would you like to learn how to perform a Prometheus monitoring Apache configuration on Ubuntu Linux? In this tutorial, we are going to show you how to install Prometheus on Ubuntu Linux, how to configure Prometheus to monitor an Apache server using the apache_exporter application and how to access your Prometheus web administration interface.

• Ubuntu version: 18.04
• Prometheus version: 2.8.0
• Prometheus apache_exporter version: 0.5.0

In our example, the Apache server uses the IP address 34.214.156.37.

In our example, the Prometheus server uses the IP address 34.210.236.85.

Keep in mind that you need to change the commands and configuration files to reflect your environment.

What is Prometheus?

Prometheus is an open-source monitoring platform that is able to collect metrics from monitored targets by scraping metrics.

After saving the collected data, a network administrator is able to query it using its query language and render all the results into graphs.

Prometheus comes with a web server that allows it to be accessed from anywhere.

Prometheus Tutorial:

On this page, we offer quick access to a list of Prometheus tutorials.

Tutorial – Prometheus apache_exporter Installation

These tasks should be performed on the computer that is running the Apache Server.

On the Linux console, create an account to the apache_exporter application.

# groupadd –system apache_exporter
# useradd -s /bin/false -r -g apache_exporter apache_exporter

Perform the download and installation of the Prometheus Apache exporter application.

# mkdir /downloads/apache_exporter -p
# cd /downloads/apache_exporter
# wget https://github.com/Lusitaniae/apache_exporter/releases/download/v0.5.0/apache_exporter-0.5.0.linux-amd64.tar.gz
# tar -zxvf apache_exporter-0.5.0.linux-amd64.tar.gz
# install apache_exporter-0.5.0.linux-amd64/apache_exporter /usr/local/bin/

Test your Apache exporter installation.

# apache_exporter -version

apache_exporter, version 0.5.0 (branch: HEAD, revision: f6a5b4814ea795ee9eac745c55649cce9e5117a9)
build user: root@0fdc4d8924f5
build date: 20171113-21:19:13
go version: go1.9.2

Create an automatic startup script to the Prometheus apache_exporter service.

# vim /etc/systemd/system/apache_exporter.service

Here is the content of the apache_exporter.service file.

Copy

Enable and start the Apache_Exporter service.

# systemctl daemon-reload
# systemctl enable apache_exporter
# systemctl start apache_exporter

Congratulations! You have successfully installed the Prometheus apache_exporter service.

Tutorial – Prometheus Install

These tasks should be performed on the computer that will become the Prometheus server.

On the Linux console, create a Prometheus user account.

# groupadd –system prometheus
# useradd -s /bin/false -r -g prometheus prometheus

Create the Prometheus required directories.

# mkdir /etc/prometheus
# mkdir /var/lib/prometheus

Perform the Prometheus download.

# mkdir /downloads/prometheus -p
# cd /downloads/prometheus
# wget https://github.com/prometheus/prometheus/releases/download/v2.8.0/prometheus-2.8.0.linux-amd64.tar.gz

Extract and Install Prometheus monitoring package.

# tar -zxvf prometheus-2.8.0.linux-amd64.tar.gz
# cd prometheus-2.8.0.linux-amd64/
# install prometheus /usr/local/bin/
# install promtool /usr/local/bin/
# mv consoles /etc/prometheus/
# mv console_libraries /etc/prometheus/

Create a Prometheus configuration file.

# cd /etc/prometheus
# vi prometheus.yml

Here is the Prometheus.yml file content.

Copy

In our example, we are assuming that the Apache server IP address is 34.214.156.37.

Keep in mind that you need to change the Apache server IP address to reflect your environment.

Set the correct permission on Prometheus installation files.

# chown prometheus:prometheus /usr/local/bin/prometheus
# chown prometheus:prometheus /usr/local/bin/promtool
# chown prometheus:prometheus /var/lib/prometheus -R
# chown prometheus:prometheus /etc/prometheus -R
# chmod -R 775 /etc/prometheus/ /var/lib/prometheus/

Use the following command to start Prometheus manually.

# prometheus –config.file /etc/prometheus/prometheus.yml –storage.tsdb.path /var/lib/prometheus/ –web.console.templates=/etc/prometheus/consoles –web.console.libraries=/etc/prometheus/console_libraries

Prometheus Startup Script.

Create a Prometheus startup script.

# vi /etc/systemd/system/prometheus.service

Here is the content of the prometheus.service file.

Copy

Enable the Prometheus service to start during the computer boot.

# chown prometheus:prometheus /var/lib/prometheus -R
# chmod 775 /var/lib/prometheus -R
# systemctl daemon-reload
# systemctl enable prometheus
# systemctl start prometheus

Prometheus Dashboard Access

Open your browser and enter the IP address of your server plus :9090

In our example, the following URL was entered in the Browser:

• http://34.216.84.149:9090

The Prometheus web interface should be presented.

On the Prometheus query textbox, enter the string apache to test the communication with apache_exporter.

prometheus dashboard

Congratulation! You have successfully performed a Prometheus installation on Ubuntu Linux.

Prometheus Targets

Open your browser and enter the IP address of your server plus :9090/targets

In our example, the following URL was entered in the Browser:

• http://34.216.84.149:9090/targets

The Prometheus target web interface should be presented.

prometheus monitoring apache

Click on the Prometheus apache_exportet target link to verify all metrics available for Apache monitoring.