Skip to content

Commit

Permalink
Update prometheus version, setup steps and update script
Browse files Browse the repository at this point in the history
  • Loading branch information
remyroy committed Nov 25, 2024
1 parent 8b2ae74 commit c6a09b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
27 changes: 7 additions & 20 deletions monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,44 +164,35 @@ $ sudo chown -R prometheus:prometheus /var/lib/prometheus
Download the latest stable version of Prometheus from https://prometheus.io/download/#prometheus (avoid any pre-release version). As of this date, the latest stable release version is 2.54.1 . Adjust the following instructions accordingly if there is a newer stable release version with a different archive name. The file name should end with *linux-amd64.tar.gz* (for linux and AMD64 instructions set).

```console
$ wget https://github.com/prometheus/prometheus/releases/download/v2.54.1/prometheus-2.54.1.linux-amd64.tar.gz
$ wget https://github.com/prometheus/prometheus/releases/download/v3.0.0/prometheus-3.0.0.linux-amd64.tar.gz
```

Verify that the SHA256 Checksum as shown on https://prometheus.io/download/#prometheus is the same as the file we just downloaded.

```console
$ sha256sum prometheus-2.54.1.linux-amd64.tar.gz
$ sha256sum prometheus-3.0.0.linux-amd64.tar.gz
```

Extract the archive.

```console
$ tar xvf prometheus-2.54.1.linux-amd64.tar.gz
$ tar xvf prometheus-3.0.0.linux-amd64.tar.gz
```

Copy the binaries to the following locations and set ownership.

```console
$ sudo cp prometheus-2.54.1.linux-amd64/prometheus /usr/local/bin/
$ sudo cp prometheus-2.54.1.linux-amd64/promtool /usr/local/bin/
$ sudo cp prometheus-3.0.0.linux-amd64/prometheus /usr/local/bin/
$ sudo cp prometheus-3.0.0.linux-amd64/promtool /usr/local/bin/
$ sudo chown -R prometheus:prometheus /usr/local/bin/prometheus
$ sudo chown -R prometheus:prometheus /usr/local/bin/promtool
```

Copy the content files to the following locations and set ownership.

```console
$ sudo cp -r prometheus-2.54.1.linux-amd64/consoles /etc/prometheus
$ sudo cp -r prometheus-2.54.1.linux-amd64/console_libraries /etc/prometheus
$ sudo chown -R prometheus:prometheus /etc/prometheus/consoles
$ sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
```

Remove the download leftovers.

```console
$ rm -rf prometheus-2.54.1.linux-amd64
$ rm prometheus-2.54.1.linux-amd64.tar.gz
$ rm -rf prometheus-3.0.0.linux-amd64
$ rm prometheus-3.0.0.linux-amd64.tar.gz
```

Setup the Prometheus configuration file. Open the YAML config file for editing.
Expand Down Expand Up @@ -247,8 +238,6 @@ Finally, let’s test the service is running correctly.
$ sudo -u prometheus /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="localhost:9090"
```
Output should look something like this. Press `Ctrl` + `C` to exit.
Expand Down Expand Up @@ -282,8 +271,6 @@ RestartSec=5
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 \
--storage.tsdb.retention.time=15d \
--web.listen-address="localhost:9090"
ExecReload=/bin/kill -HUP $MAINPID
Expand Down
12 changes: 0 additions & 12 deletions scripts/update-prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,6 @@ def update_prometheus(release_data):
subprocess.run(['sudo', 'chown', '-R', PROMETHEUS_USER_GROUP, installed_prometheus_path])
subprocess.run(['sudo', 'chown', '-R', PROMETHEUS_USER_GROUP, installed_promtool_path])

print('Updating installed Prometheus content...')
extracted_consoles_path = extracted_directory + '/' + 'consoles'
extracted_console_libraries_path = extracted_directory + '/' + 'console_libraries'
installed_consoles_path = PROMETHEUS_DATA_PATH + 'consoles'
installed_console_libraries_path = PROMETHEUS_DATA_PATH + 'console_libraries'
subprocess.run(['sudo', 'rm', '-rf', installed_consoles_path])
subprocess.run(['sudo', 'rm', '-rf', installed_console_libraries_path])
subprocess.run(['sudo', 'cp', '-r', extracted_consoles_path, PROMETHEUS_DATA_PATH])
subprocess.run(['sudo', 'cp', '-r', extracted_console_libraries_path, PROMETHEUS_DATA_PATH])
subprocess.run(['sudo', 'chown', '-R', PROMETHEUS_USER_GROUP, installed_consoles_path])
subprocess.run(['sudo', 'chown', '-R', PROMETHEUS_USER_GROUP, installed_console_libraries_path])

print('Restarting Prometheus service...')
subprocess.run(['sudo', 'systemctl', 'start', PROMETHEUS_SERVICE_NAME])
else:
Expand Down

0 comments on commit c6a09b4

Please sign in to comment.