Prometheus is an open-source systems monitoring and alerting toolkit designed for reliability and scalability. Combined with Node Exporter, it provides powerful metrics about your system's performance. In this guide, we will walk through the steps to install Prometheus and Node Exporter on Rocky Linux.

Step 1: Update Your System

Start by ensuring your system is up to date:

sudo dnf update -y

Step 2: Create a Prometheus User

Create a user for Prometheus to run under:

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

Step 3: Install Prometheus

Download the latest version of Prometheus from the official GitHub repository:

wget https://github.com/prometheus/prometheus/releases/latest/download/prometheus-*.tar.gz

Extract the downloaded archive:

tar -xvf prometheus-*.tar.gz

Move the binaries to the appropriate directories:

sudo mv prometheus-*/prometheus /usr/local/bin/
sudo mv prometheus-*/promtool /usr/local/bin/

Step 4: Create Directories for Prometheus

Create the necessary directories for configuration and data:

sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus

Move the configuration files:

sudo mv prometheus-*/prometheus.yml /etc/prometheus/

Step 5: Set Permissions

Change the ownership of the directories to the Prometheus user:

sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
sudo chown -R prometheus:prometheus /var/lib/prometheus

Step 6: Create a Systemd Service for Prometheus

Create a service file for Prometheus:

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

Add the following configuration:

[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.listen-address="0.0.0.0:9090"

[Install]
WantedBy=multi-user.target

Step 7: Start and Enable Prometheus

Reload the systemd daemon and start the Prometheus service:

sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus

Step 8: Install Node Exporter

Download the latest version of Node Exporter:

wget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-*.tar.gz

Extract the downloaded archive:

tar -xvf node_exporter-*.tar.gz

Move the Node Exporter binary:

sudo mv node_exporter-*/node_exporter /usr/local/bin/

Step 9: Create a Systemd Service for Node Exporter

Create a service file for Node Exporter:

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

Add the following configuration:

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

[Service]
User=nobody
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

Step 10: Start and Enable Node Exporter

Reload the systemd daemon and start the Node Exporter service:

sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter

Step 11: Configure Prometheus to Scrape Node Exporter

Edit the Prometheus configuration file to add Node Exporter as a target:

sudo nano /etc/prometheus/prometheus.yml

Add the following lines under scrape_configs::

- job_name: 'node_exporter'
  static_configs:
    - targets: ['localhost:9100']

Step 12: Restart Prometheus

Restart the Prometheus service to apply the changes:

sudo systemctl restart prometheus

Conclusion

You have successfully installed Prometheus and Node Exporter on Rocky Linux. This powerful combination will help you monitor your systems effectively.

If you're looking for a reliable hosting solution for your monitoring stack, consider using Windows VPS UK. With Windows VPS, you can efficiently host your applications and ensure high performance. Whether you need VPS UK Windows or Windows Virtual Private Servers, you'll find a solution that fits your requirements.

For larger deployments or enterprise needs, explore Windows Virtual Dedicated Server Hosting or Virtual Private Server Hosting Windows. Whether you're located in the UK, Italy, or elsewhere, Windows VPS Italy and UK VPS Windows offer reliable hosting options. Visit Windows VPS Hosting UK to discover the best hosting solutions for your Prometheus deployment.

Was dit antwoord nuttig? 0 gebruikers vonden dit artikel nuttig (0 Stemmen)