How to Install Prometheus on Clear Linux Latest

Prometheus is an open-source monitoring system and time-series database that helps to monitor service-level targets, collect and analyze metrics for resources. In this tutorial, we will show you the step-by-step process of installing Prometheus on Clear Linux Latest.

Prerequisites:

  1. A Clear Linux Latest installation.
  2. A sudo user.

Step 1: Update Your System

Before proceeding with the installation process of Prometheus, it is recommended that you update your system to the latest packages. You can update your Clear Linux by running the following command:

sudo swupd update

Step 2: Install Go and Git

Prometheus is built using the Go programming language, so we need to install Go and Git. We can install them by running the following command:

sudo swupd bundle-add go-basic git

Step 3: Download and Install Prometheus

  1. Navigate to the Prometheus website prometheus.io and click on the "Download" button on the top-right corner of the page.
  2. Choose the latest version of Prometheus that is compatible with Clear Linux.
  3. Run the following command to download the latest version of Prometheus:
wget https://github.com/prometheus/prometheus/releases/download/v2.30.0/prometheus-2.30.0.linux-amd64.tar.gz

Note: Replace the link with the relevant link of your selected version.

  1. Extract the downloaded file by running the following command:
tar -xvf prometheus-2.30.0.linux-amd64.tar.gz
  1. Rename the Prometheus directory for easy reference and move it to the /usr/local directory by running the following commands:
sudo mv prometheus-2.30.0.linux-amd64 prometheus
sudo mv prometheus /usr/local/

Step 4: Create a User for Prometheus

It is recommended to run Prometheus as a non-root user for security purposes. Create a user and group for Prometheus by running the following command:

sudo useradd --no-create-home --shell /bin/false prometheus

Step 5: Assign Permissions to the Prometheus Folders

Grant ownership permissions for the Prometheus directories to the prometheus user:

sudo chown -R prometheus:prometheus /usr/local/prometheus

Step 6: Create a Systemd Service File for Prometheus

We need to create a Prometheus Systemd service file to start Prometheus on system boot. Run the following command to create the service file:

sudo nano /etc/systemd/system/prometheus.service

Paste the following contents into the file:

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
ExecStart=/usr/local/prometheus/prometheus \
  --config.file /usr/local/prometheus/prometheus.yml \
  --storage.tsdb.path /var/lib/prometheus/ \
  --web.console.templates=/usr/local/prometheus/consoles \
  --web.console.libraries=/usr/local/prometheus/console_libraries

[Install]
WantedBy=multi-user.target

Step 7: Reload Systemd and Start Prometheus

Reload Systemd to pick up the new service file.

sudo systemctl daemon-reload

Start Prometheus.

sudo systemctl start prometheus

Step 8: Verify Prometheus is Running

Check the status of Prometheus by running the following command:

systemctl status prometheus

You should see the output indicating that Prometheus is active and running.

● prometheus.service - Prometheus
     Loaded: loaded (/etc/systemd/system/prometheus.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-02-22 03:43:34 UTC; 14s ago
   Main PID: 708863 (prometheus)
      Tasks: 7 (limit: 235854)
     Memory: 41.7M
        CPU: 357ms
     CGroup: /system.slice/prometheus.service
             └─708863 /usr/local/prometheus/prometheus --config.file /usr/local/prometheus/prometheus.yml --storage.tsdb.path /var/lib/prometheus/ --web.console.templates=/usr/local/prometheus/consoles --web.console.libraries=/usr/local/prometheus>

Conclusion:

You have successfully installed Prometheus on Clear Linux Latest. You can now configure Prometheus and use it to monitor your applications, servers, and services.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!