Install Prometheus and Grafana on Ubuntu 18

by Daniel Pham
Published: Updated:
This entry is part 1 of 14 in the series Install Prometheus and Grafana on Ubuntu 18

In this article, I will guide you to install Prometheus and Grafana on Ubuntu 18.04.

For those of you who don’t know what these 2 tools are?

What are Prometheus and Grafana?

Let me summarize:

  • Prometheus is an open source monitoring and alerting tool. Developed by SoundCloud since 2012, it supports time series data, similar to InfluxDB.
  • Grafana is a “graphing” tool that allows you to query and draw visual tables/charts based on available data.

So what do we get when we combine Prometheus and Grafana? Prometheus collects monitoring data from endpoints (servers, switches, firewalls, websites…). Grafana will display charts based on Prometheus data.

Install Prometheus and Grafana on Ubuntu 18
Install prometheus and grafana on ubuntu 18.

Prepare Ubuntu 18 server

To get started, you can use Ubuntu server 18 with the following configuration:

  • 1 vCPU
  • 1 GB RAM
  • 40 GB HDD
  • OS: Ubuntu server 18.04
  • User: root

For larger systems, you need to customize the configuration according to the level of system usage.

Initial settings for the server

You will need to execute a few commands before installing the main tools.

Update packages.

apt update

Set up timezone.

timedatectl set-timezone "Asia/Ho_Chi_Minh"
timedatectl set-ntp true
systemctl restart systemd-timesyncd

Install IPtables firewall (if you want).

apt install iptables-persistent netfilter-persistent -y

Install Prometheus on Ubuntu 18

First you need to determine the latest version to use according to this link.

export RELEASE="2.20.1"

Download and extract the installation package.

tar xvf prometheus-${RELEASE}.linux-amd64.tar.gz
cd prometheus-${RELEASE}.linux-amd64/

Create a user for the Prometheus service.

groupadd --system prometheus
grep prometheus /etc/group
useradd -s /sbin/nologin -r -g prometheus prometheus

Create a directory containing the Prometheus configuration file.

mkdir -p /etc/prometheus/{rules,rules.d,files_sd}  /var/lib/prometheus

Move the binary executable files to the local bin folder and copy the consoles folder, config file.

cp prometheus promtool /usr/local/bin/
cp -r consoles/ console_libraries/ /etc/prometheus/
cp prometheus.yml /etc/prometheus/

Assign permissions to the prometheus user.

chown -R prometheus:prometheus /etc/prometheus/ /var/lib/prometheus/
chmod -R 775 /etc/prometheus/ /var/lib/prometheus/

Create systemd file for prometheus service.

nano /etc/systemd/system/prometheus.service

Copy the content below into the file.

Description=Prometheus systemd service unit

ExecReload=/bin/kill -HUP $MAINPID
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 \
--web.listen-address= \



Enable and start the prometheus service.

systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus

Now you can access the browser IP:9090 to enter the prometheus program interface. For example: By default, the prometheus program interface will not have any lock/login protection layer.

Install Grafana on Ubuntu 18

Now, we will install Grafana and this is much simpler than installing prometheus.

First, you add the Grafana repository to the server.

echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
wget -q -O - | sudo apt-key add

Next, you update the software packages from this repository and install Grafana.

apt-get update
apt-get install grafana -y

After installation is complete, you activate and start the service.

systemctl start grafana-server
systemctl enable grafana-server.service

Now you can open your browser and access IP:3000. For example: The default grafana login account is admin/admin. On your first visit, you will have to change the new password for the admin user.


So I have guided you to install the two tools Prometheus and Grafana on the Ubuntu 18.04 server. In the next articles, I will guide you through the necessary settings and how to use these two tools.

0 0 votes
Article Rating
Series NavigationNext part: Set up nginx proxy for Prometheus and Grafana »»

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.