Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Linux » Install and configure Prometheus for Monitoring on a Linux

Install and configure Prometheus for Monitoring on a Linux

Posted on 03/04/202206/01/2024 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on Install and configure Prometheus for Monitoring on a Linux
FEATURE-IMAGE-IMAGE

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.

Prometheus Attributes

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.

Requirements

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.

DPROMETHEUS-1
download prometheus

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
tarx
extract & rename

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.

Also, see AD LDS and AD DS: Differences between Active Directory Lightweight Directory Services and Active Directory Domain Services, and how to set up Cisco ASA – wipe old configurations.

Configure Prometheus

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
status-1

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

http://<prometheus-ip>:9090/graph

You should be able to view the UI depicted below.

prometheus-ui
Prometheus ui

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.

endpoint
endpoint well configured

Summary

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.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:Monitoring

Post navigation

Previous Post: How to Install Kubectl on Windows 11
Next Post: How to grant public access to S3 Bucket using Policy

Related Posts

  • Webp.net resizeimage 1
    Automate Infrastructure Deployments in the Cloud with Ansible and Azure Pipelines AWS/Azure/OpenShift
  • PRIVATE DOCKER REGISTRY
    How to Set up Private Docker Registry Containers
  • image 10
    Change Visual Studio Code UI language JIRA|Confluence|Apps
  • centos feature
    How to change the system time zone under RedHat and CentOS Linux
  • Screenshot 2022 04 13 at 21.38.35
    Check Weather Conditions via Command Line on Windows, macOS, Linux and Web Linux
  • 517443 637286201540125528 16x9 1
    User account and process management in Linux Linux

More Related Articles

Webp.net resizeimage 1 Automate Infrastructure Deployments in the Cloud with Ansible and Azure Pipelines AWS/Azure/OpenShift
PRIVATE DOCKER REGISTRY How to Set up Private Docker Registry Containers
image 10 Change Visual Studio Code UI language JIRA|Confluence|Apps
centos feature How to change the system time zone under RedHat and CentOS Linux
Screenshot 2022 04 13 at 21.38.35 Check Weather Conditions via Command Line on Windows, macOS, Linux and Web Linux
517443 637286201540125528 16x9 1 User account and process management in Linux Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • xyxc
    How to link a removable media to a Deployment Share: Replicate Deployment share to a removable device Windows Server
  • Featured Image new
    Add Registry Keys via DISM in Windows Windows
  • Featured Image Windows Security
    How to protect your Windows PC from potentially unwanted applications Security | Vulnerability Scans and Assessment
  • settings app not working featured 800x400 1
    Disable or Remove Kiosk Mode Via the Local Settings Windows
  • featured 2 2
    Clone a repository and install software from GitHub on Windows Windows Server
  • RemoteDesktopLinceseServer
    Fix Remote session was disconnected because there are no Remote Desktop License Servers available to provide a license Network | Monitoring
  • WindowsCoreSecurity
    How to enable Smart App Control on Windows 11 Security | Vulnerability Scans and Assessment
  • Could not load file or assembly
    Unable to edit MDT XML unattended file: Could not load file Windows Server

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,825 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.