Would you like to learn how to perform a Prometheus monitoring installation on Ubuntu Linux? In this tutorial, we are going to show you how to install Prometheus on Ubuntu Linux and how to access your Prometheus web administration interface for the first time.

• Ubuntu version: 18.04
• Prometheus version: 2.8.0

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 Install

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

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

You should see the following log messages.

Copy

Prometheus Startup Script.

Create a Prometheus startup script.

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

Here is the content of the prometheus.service file.

[Unit]

Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]

User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/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

[Install]

WantedBy=multi-user.target
SyslogIdentifier=prometheus
Restart=always

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

The Prometheus service will start listening on TCP port 9090.

Use the following command to check the status of the Prometheus service.

# systemctl status prometheus

Here is an example of the Prometheus service status output

● prometheus.service – Prometheus
Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-27 02:59:44 UTC; 22h ago
Main PID: 29882 (prometheus)
Tasks: 8 (limit: 1152)
CGroup: /system.slice/prometheus.service
└─29882 /usr/local/bin/prometheus –config.file /etc/prometheus/prometheus.yml –storage.tsdb.path /var/lib/prometheus/ –web.console.templates=/etc/prometheus/consoles –web.console.lib

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.

prometheus dashboard

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