Prometheus, an open-source monitoring system, is renowned for its multi-dimensional data model, flexible query language, and self-sufficient server nodes. This article provides a step-by-step guide to efficiently install Prometheus on openSUSE. The tutorial assumes a basic understanding of Linux and shell usage. It is also expected that your site is hosted on your own VPS.
Installation Steps
Step 1: System Update
Start by refreshing and updating your system with the zypper package manager:
sudo zypper refresh sudo zypper update
Step 2: Installing Prometheus
Download the latest Prometheus binary from theofficial website:
wget https://github.com/prometheus/prometheus/releases/download/v2.49.1/prometheus-2.49.1.linux-amd64.tar.gz
Next, extract the file and rename the extracted folder to prometheus-files:
tar -xvf prometheus-2.49.1.linux-amd64.tar.gz mv prometheus-2.49.1.linux-amd64 prometheus-files
Afterward, move the Prometheus files to the /etc/prometheus directory and assign ownership to the prometheus user:
sudo cp -r prometheus-files/consoles /etc/prometheus sudo cp -r prometheus-files/console_libraries /etc/prometheus sudo chown -R prometheus:prometheus /etc/prometheus
Step 3: Configuring Prometheus
Create and edit the prometheus.yml file:
sudo nano /etc/prometheus/prometheus.yml
Embed the given content:
global: scrape_interval: 10s scrape_configs: - job_name: 'prometheus' scrape_interval: 5s static_configs: - targets: ['localhost:9090']
Change the file’s ownership to the prometheus user:
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Step 4: Setting Up Prometheus as a Service
Create a Prometheus service file:
sudo nano /etc/systemd/system/prometheus.service
Add the following content to the file:
[Unit] Description=Prometheus Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple 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 [Install] WantedBy=multi-user.target
Reload the systemd manager configuration:
sudo systemctl daemon-reload
Start the Prometheus service and enable it to start at boot:
sudo systemctl start prometheus sudo systemctl enable prometheus
Step 5: Installing and Configuring Node Exporter
Node Exporter is a Prometheus exporter for hardware and OS metrics with pluggable metric collectors. It measures various machine resources such as memory, disk I/O, CPU, network, etc.
Download and set up Node Exporter:
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz tar -xvf node_exporter-1.7.0.linux-amd64.tar.gz mv node_exporter-1.7.0.linux-amd64 node_exporter-files
Copy the Node Exporter binary to /usr/bin and change the ownership to the node_exporter user:
sudo cp node_exporter-files/node_exporter /usr/bin/ sudo chown node_exporter:node_exporter /usr/bin/node_exporter
Create a Node Exporter service file:
sudo nano /etc/systemd/system/node_exporter.service
Add the following configuration:
[Unit] Description=Node Exporter After=network.target [Service] User=node_exporter ExecStart=/usr/bin/node_exporter [Install] WantedBy=default.target
Reload the systemd manager configuration, start the Node Exporter service, and enable it to start at boot:
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
Step 6: Configuring Firewall Rules
If your firewall is enabled and running, add rules to allow access to Prometheus and Node Exporter ports:
sudo firewall-cmd --permanent --zone=public --add-port=9090/tcp sudo firewall-cmd --permanent --zone=public --add-port=9100/tcp sudo firewall-cmd --reload
Step 7: Accessing Prometheus Web UI
Once Prometheus is successfully installed, open your web browser and navigate to http://<your-server-ip>:9090. You should see the Prometheus dashboard.
Congratulations! You have successfully installed Prometheus on your openSUSE system. This article has provided a comprehensive guide to ensure a smooth and efficient installation process. For additional information, consult the official Prometheus website.
If managing your VPS seems overwhelming, or you simply don’t have the time, consider utilizing managed VPS services like those offered by Shape.host. They offer Cloud VPS, providing a hassle-free solution for your server management needs.