Upgrading Prometheus from 2.X to the latest versions 2.17.X/2.19.X

Rakesh Jain
3 min readApr 21, 2020

In this tutorial you’ll upgrade an existing Prometheus 2.x installation to the latest version of Prometheus which is 2.17.2
This tutorial covers only the most important changes.

Prerequisites

To follow this tutorial you’ll need:

  • One Linux server set up
  • Prometheus 2.x installed on your server, including the Prometheus Web UI. You can find out your Prometheus version by running the prometheus -version command. The output contains your Prometheus version as well as build information.

This tutorial assumes the following things about your Prometheus installation:

  • You have created a prometheus user.
  • You have created the directory /etc/prometheus which holds Prometheus’s configuration files.
  • You have created the directory /var/lib/prometheus which holds Prometheus’s data.
  • The prometheus and promtool executables are located in /usr/local/bin.
  • You have configured Prometheus to run as a systemd service called prometheus.

The current version running is -

# prometheus — version
prometheus, version 2.10.0 (branch: HEAD, revision: d20e84d0fb64aff2f62a977adc8cfb656da4e286)
build user: root@a49185acd9b0
build date: 20190525–12:28:13
go version: go1.12.5

Stop all the running services for a while till we are done with upgrade process.

systemctl stop prometheus.service
systemctl stop alertmanager.service
systemctl stop blackbox.service
systemctl stop grafana-server.service

Download the Prometheus archive and checksum -
You can find Prometheus 2.17.2 along with checksums on the project’s GitHub Releases page. You need a file called prometheus-2.17.2.linux-amd64.tar.gz. Using the following curl commands, download the Prometheus archive and checksum to your home directory:

wget https://github.com/prometheus/prometheus/releases/download/v2.17.2/prometheus-2.17.2.linux-amd64.tar.gzwget -O — -q https://github.com/prometheus/prometheus/releases/download/v2.17.2/sha256sums.txt | grep linux-amd64 | shasum -c -

Now, unpack the archive -

tar -xvf prometheus-2.17.2.linux-amd64.tar.gz
cd prometheus-2.17.2.linux-amd64/

Copy the prometheus and promtool executables to the /usr/local/bin directory -

cp prometheus-2.17.2.linux-amd64/{prometheus,promtool} /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/{prometheus,promtool}

Copy the console libraries and change the ownership -

cp -r prometheus-2.17.2.linux-amd64/{consoles,console_libraries} /etc/prometheus/
chown -R prometheus:prometheus /etc/prometheus

Verify the content of Prometheus data directory -

ls -l /var/lib/prometheus

Finally Restart all the services -

systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
systemctl start alertmanager.service
systemctl start blackbox.service
systemctl start grafana-server.service

Verify the Prometheus Version -

prometheus — version
prometheus, version 2.17.2 (branch: HEAD, revision: 18254838fbe25dcc732c950ae05f78ed4db1292c)
build user: root@9cb154c268a2
build date: 20200420–08:27:08
go version: go1.13.10

Update as of July 1st 2020 — →

The latest version is 2.19.2. And by following the same procedure it can be upgraded to this version.

https://github.com/prometheus/prometheus/releases

#systemctl stop prometheus.service
#systemctl stop alertmanager.service
#systemctl stop blackbox.service
#systemctl stop grafana-server.service
#wget https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz#tar -xvf prometheus-2.19.2.linux-amd64.tar.gz#cp prometheus-2.19.2.linux-amd64/{prometheus promtool} /usr/local/bin/#cp -r prometheus-2.19.2.linux-amd64/{consoles,console_libraries} /etc/prometheus/#chown -R prometheus:prometheus /etc/prometheus#ls -l /var/lib/prometheus#systemctl daemon-reload
#systemctl start prometheus
#systemctl enable prometheus
#systemctl start alertmanager.service
#systemctl start blackbox.service
#systemctl start grafana-server.service
#systemctl status prometheus.service
# prometheus — version
prometheus, version 2.19.2 (branch: HEAD, revision: c448ada63d83002e9c1d2c9f84e09f55a61f0ff7)
build user: root@dd72efe1549d
build date: 20200626–09:02:20
go version: go1.14.4

Hope you like the tutorial. Please let me know your feedback in the response section.

Happy learning!

--

--

Rakesh Jain
Rakesh Jain

Written by Rakesh Jain

DevOps Professional | Technical writer

Responses (3)