How to install and configure Prometheus on Ubuntu 18.04?
Prometheus is a powerful open-source monitoring and alerting system that helps you monitor various aspects of your system such as server metrics, network metrics, application metrics, and more. In this blog post, we will discuss how to install and configure Prometheus on Ubuntu 18.04.
Step 1: Update and Upgrade the Ubuntu System
Before installing Prometheus, it is recommended to update and upgrade the Ubuntu system to ensure that all the packages are up-to-date.
To update and upgrade the system, open the terminal and run the following commands
sudo apt-get update
sudo apt-get upgrade
Step 2: Install Prometheus
To install Prometheus on Ubuntu 18.04, follow these steps
Download the latest Prometheus release using the following command
wget https://github.com/prometheus/prometheus/releases/download/v2.27.1/prometheus-2.27.1.linux-amd64.tar.gz
Extract the downloaded file using the following command
tar xvfz prometheus-2.27.1.linux-amd64.tar.gz
Move the extracted folder to /opt directory using the following command
sudo mv prometheus-2.27.1.linux-amd64 /opt/prometheus
Step 3: Configure Prometheus
After installing Prometheus, you need to configure it by creating a configuration file. To create the configuration file, follow these steps
Create a configuration file named prometheus.yml in the /opt/prometheus directory using the following command
sudo nano /opt/prometheus/prometheus.yml
Add the following content to the file
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
Save and close the file by pressing Ctrl+X and then Y.
Step 4: Start Prometheus
To start Prometheus, follow these steps
Change the directory to /opt/prometheus using the following command
cd /opt/prometheus
Start Prometheus using the following command
./prometheus
Open a web browser and go to http://localhost:9090 to access the Prometheus dashboard.
Step 5: Add Prometheus as a System Service
To run Prometheus as a system service, follow these steps
Create a systemd unit file using the following command
sudo nano /etc/systemd/system/prometheus.service
Add the following content to the file
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=prometheus
Restart=on-failure
ExecStart=/opt/prometheus/prometheus
--config.file /opt/prometheus/prometheus.yml
--storage.tsdb.path /opt/prometheus/data
[Install]
WantedBy=multi-user.target
Save and close the file by pressing Ctrl+X and then Y.
Reload the systemd daemon using the following command
sudo systemctl daemon-reload
Enable and start the Prometheus service using the following commands
sudo systemctl enable prometheus
sudo systemctl start prometheus
Conclusion
In this blog post, we discussed how to install and configure Prometheus on Ubuntu 18.04. With this monitoring tool, you can monitor your system and receive alerts whenever any issues occur. By following the steps outlined above, you can quickly set up Prometheus and start using it to monitor your system.
Comments
Post a Comment
Comments are always welcome, that will help us to motivate ourselves and improve our services. Thanks!!