How to install Prometheus on linux.🎯

How to install Prometheus  on linux.🎯

Prometheus is an open-source monitoring and alerting toolkit designed for collecting and analyzing metrics as time-series data. It uses a pull-based model to scrape metrics, supports dynamic service discovery, and offers a flexible query language (PromQL). Commonly used in cloud-native environments, it integrates well with tools like Grafana for visualization and Alertmanager for notifications. Prometheus is scalable, reliable, and ideal for monitoring modern, distributed systems.

Download the prometheus zip-file.

command: wget https://github.com/prometheus/prometheus/releases/download/v2.35.0/prometheus-2.35.0.linux-amd64.tar.gz

unzip prometheus zip-file.

command: tar -xvfz prometheus-2.35.0.linux-amd64.tar.gz

Go to that directory.

command: cd prometheus-2.35.0.linux-amd64

run

./prometheus --config.file=prometheus.yml

Stop the running Prometheus process that we left running, and copy the new files to bin folder in prometheus.

command: cp -r . /usr/local/bin/prometheus/

Create a file called prometheus.service.

command: vim /etc/systemd/system/prometheus.service

Add this script on that prometheus.service and save.

[Unit]
Description=Prometheus Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/prometheus/prometheus --config.file=/usr/local/bin/prometheus/prometheus.yml

[Install]
WantedBy=multi-user.target

Now, check the status.

command: sudo service prometheus start
sudo service prometheus status

Go to the web browser.

ip_adress:9090 eg-192.x.x.x:9090

(note-if you are facing a problem you have to open the port.)

Allowing incoming TCP connections on port 9090.

command: sudo iptables -A INPUT -p tcp --dport 9090 -j ACCEPT

Restart the prometheus.

command: sudo systemctl restart prometheus

➡Conclusion:

Installing Prometheus on a Linux system involves downloading the Prometheus binary, setting it up as a service for easy management, and ensuring network access to its web interface. By following the steps provided, you can successfully deploy Prometheus and start monitoring your system or application metrics. If any issues arise, such as port access problems, they can be resolved by configuring firewall rules. This setup ensures Prometheus runs seamlessly as a service and is accessible via the browser for real-time monitoring.

If you have any questions or face issues, feel free to drop a comment below or mail me at !