Prometheus is a lightweight open-source monitoring system with an effective alerting system. In this article, we shall discuss how to “Install and configure Prometheus for Monitoring on a Linux”. Prometheus gathers and saves metrics as time-series data, which means that metric data is kept alongside the timestamp at which it was captured, as well as additional key-value pairs known as labels. Other tutorials can be found here: How to install PostgreSQL on Ubuntu, How to install Apache Tomcat on Ubuntu, How to install Node.js on Ubuntu, How to install PostgreSQL on Ubuntu, how to install Gradle on Ubuntu, and how to install and configure Tripwire on Ubuntu.
More information about Prometheus can be obtained. This tutorial will teach you how to install and configure Prometheus for Monitoring on a Linux Server. Prometheus will be downloaded, installed, and executed. Here is a video on how to Install and configure Prometheus for Monitoring on a Linux Server.
The following are some attributes of Prometheus.
1: Time-series data identifiable by metric name and key/value pairs in an inter-data model 2: Uses PromQL for Querying and PromQL is a versatile query language 3: That allows you to make use of the dimensionality without relying on distributed storage. 4: Single server nodes are self-contained, and time series are collected using a pull model over HTTP. 5: Pushing time series is possible with the help of an intermediate gateway. 6: Service discovery or static configuration is used to discover targets. 7: Service discovery or static configuration is used to discover targets.
Be sure you have sudo access to the Linux server. The server has internet connectivity and can download the Prometheus binaries.
On the server, firewall rules are opened to allow access to Prometheus port 9090.
Please see How to use Prometheus for Monitoring, Install Grafana on Windows and Windows Server, how to Change Visual Studio Code UI language, Performance and Diagnostics in Microsoft Cloud with Azure Monitor, and About AD LDS: Active Directory Lightweight Directory Services.
Steps to Install and Configure Prometheus
To achieve this, we will need to configure Prometheus Binaries.
1: Update the apt package repositories.
sudo apt update
2: Go to the official Prometheus downloads page and get the latest download link for the Linux binary.
3: extract using the tar command, and rename the extracted folder to Prometheus files.
tar -xvf prometheus-2.35.0.linux-amd64.tar.gz mv prometheus-2.35.0.linux-amd64 prometheus-files
4: Create a Prometheus user, the necessary directories, and make Prometheus the owner of those directories.
sudo useradd --no-create-home --shell /bin/false prometheus sudo mkdir /etc/prometheus sudo mkdir /var/lib/prometheus sudo chown prometheus:prometheus /etc/prometheus sudo chown prometheus:prometheus /var/lib/prometheus
5: Change the ownership to the Prometheus user and copy the Prometheus and promtool binaries from the Prometheus files folder to /usr/local/bin.
sudo cp prometheus-files/prometheus /usr/local/bin/ sudo cp prometheus-files/promtool /usr/local/bin/ sudo chown prometheus:prometheus /usr/local/bin/prometheus sudo chown prometheus:prometheus /usr/local/bin/promtool
Step 6: Transfer the consoles and console libraries folders from Prometheus files to the /etc/prometheus folder and assign the consoles and console libraries directories to the Prometheus user.
The /etc/prometheus/Prometheus.yml file should contain all Prometheus configurations.
1: Create the prometheus.yml file.
sudo vi /etc/prometheus/prometheus.yml
2: Copy the following contents to the prometheus.yml file.
global: scrape_interval: 10s scrape_configs: - job_name: 'prometheus' scrape_interval: 5s static_configs: - targets: ['localhost:9090']
3: Change the ownership of the file to Prometheus user.
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Setup Prometheus Service File
1: Create a Prometheus service file.
sudo vi /etc/systemd/system/prometheus.service
2: Copy 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
3: Reload the systemd service to register the Prometheus service and start the Prometheus service.
sudo systemctl daemon-reload sudo systemctl start prometheus
Check the Prometheus service
sudo systemctl status prometheus
Access Prometheus Web UI
You may now access the Prometheus UI through the Prometheus server’s 9090 port.
To get the IP address type the command below
ip address show
To navigate to Prometheus UI type the command below and substitute the IP address of your environment
You should be able to view the UI depicted below.
We have just finished configuring the Prometheus server. To obtain metrics from the source systems, you must first register the target in the Prometheus.yml file.
If you wish to monitor 10 servers, for example, the IP addresses of these servers should be included as targets in the Prometheus setup to scrape the metrics.
The Node Exporter should be installed on the server to capture all system metrics and make them available for Prometheus to scrape.
We installed and configured Prometheus on a Ubuntu machine.
And as you can see from the last screenshot, the state says up and this indicates that everything was well configured and working properly.
I hope you found this article on how to Install and configure Prometheus for Monitoring on a Linux Server useful. If you have any questions, please let me know in the comment session.