Prometheus is a powerful open-source monitoring and alerting toolkit widely used for system monitoring and service monitoring. In this guide, we will walk you through the steps to install Prometheus on Ubuntu 20.04, making it ideal for users utilizing windows vps uk for their applications.

Step 1: Update Your System

Before installing Prometheus, ensure your system is up-to-date. Open your terminal and run:

sudo apt update && sudo apt upgrade -y

Step 2: Create a Prometheus User

For security reasons, it’s a good practice to run Prometheus under a dedicated user. Create a new user:

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

Step 3: Create Required Directories

Next, create the directories for Prometheus configuration and data:

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

Step 4: Download Prometheus

Go to the Prometheus download page and grab the latest version link. Use wget to download it directly:

wget https://github.com/prometheus/prometheus/releases/download/v2.XX.X/prometheus-2.XX.X.linux-amd64.tar.gz

Replace 2.XX.X with the latest version number.

Step 5: Extract the Package

Once downloaded, extract the tarball:

tar xvf prometheus-*.tar.gz

Step 6: Move Binaries

Move the binaries to /usr/local/bin:

sudo mv prometheus-2.XX.X.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-2.XX.X.linux-amd64/promtool /usr/local/bin/

Step 7: Set Permissions

Set the ownership of the directories and files:

sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool

Step 8: Configure Prometheus

Create the Prometheus configuration file:

sudo nano /etc/prometheus/prometheus.yml

Here’s a basic configuration:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

Step 9: Create a Systemd Service File

Create a service file to manage Prometheus as a service:

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

Add the following content:

[Unit]
Description=Prometheus
After=network.target

[Service]
User=prometheus
Group=prometheus
Restart=always
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.dir=/var/lib/prometheus/

[Install]
WantedBy=multi-user.target

Step 10: Start Prometheus

Reload the systemd manager configuration, start Prometheus, and enable it to start on boot:

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

Step 11: Access Prometheus Web Interface

Prometheus runs on port 9090 by default. Open your web browser and go to:

http://your-server-ip:9090

You will see the Prometheus web interface, ready for monitoring.

Conclusion

Now you have successfully installed Prometheus on Ubuntu 20.04. This powerful monitoring tool is perfect for those running services on a vps uk windows.

For more reliable virtual private server hosting windows, check out Windows VPS UK.

Hai trovato utile questa risposta? 0 Utenti hanno trovato utile questa risposta (0 Voti)