How to upgrade Prometheus from 2.22 to 2.38 on Ubuntu
OS : Ubuntu 16.04 LTS
Prometheus version : 2.22
# /usr/local/bin/prometheus --version
prometheus, version 2.22.0 (branch: HEAD, revision: 0a7fdd3b76960808c3a91d92267c3d815c1bc354)
Confirm that prometheus datas are in # ll /var/lib/prometheus
Take a backup of this data to a safe location
Confirm the path of prometheus and promtool # /usr/local/bin/
Take a backup of this data to a safe location
Stop prometheus and grafana services
# systemctl stop prometheus
# systemctl stop grafana-server
Download the latest prometheus. In my case its 2.38 and I downloaded to /mnt folder.
# cd /mnt
# wget https://github.com/prometheus/prometheus/releases/download/v2.38.0/prometheus-2.38.0.linux-amd64.tar.gz
# tar -xvf prometheus-2.38.0.linux-amd64.tar.gz
# cd prometheus-2.38.0.linux-amd64
# cp prometheus /usr/local/bin/
# cp promtool /usr/local/bin/
# chown prometheus:prometheus /usr/local/bin/prometheus
# chown prometheus:prometheus /usr/local/bin/promtool
# cp -r consoles /etc/prometheus/
# cp -r console_libraries /etc/prometheus/
# chown -R prometheus:prometheus /etc/prometheus
Start prometheus and grafana services
# systemctl start prometheus
# systemctl start grafana-server
Check the prometheus version
# /usr/local/bin/prometheus --version
prometheus, version 2.38.0 (branch: HEAD, revision: 818d6e60888b2a3ea363aee8a9828c7bafd73699)