Installing Prometheus on Ubuntu 22.04

Prometheus is an open-source monitoring and alerting toolkit designed for reliability and scalability of systems and applications. It was originally developed by SoundCloud and later donated to the Cloud Native Computing Foundation (CNCF). Prometheus is widely used in the field of DevOps and system administration for monitoring and observability purposes.

Key features of Prometheus include:

  • Data Model: Prometheus uses a multidimensional data model with time series data identified by metric name and key-value pairs. This allows flexible querying and aggregation of data.
  • Query Language: Prometheus Query Language (PromQL) is a powerful language for querying and manipulating the time series data collected by Prometheus.
  • Data Collection: Prometheus collects metrics from instrumented targets via HTTP endpoints. It supports various client libraries for different programming languages to facilitate the instrumentation of applications.
  • Alerting: Prometheus has a built-in alerting system that allows users to define alert conditions based on the collected metrics. Alerts can be sent to various notification channels, such as email, Slack, or other communication tools.
  • Time Series Database: Prometheus has its own time series database optimized for high write and query performance, making it well-suited for real-time monitoring.
  • Service Discovery: Prometheus supports service discovery mechanisms, allowing it to dynamically discover and monitor new instances of services as they come online or go offline.
  • Exporters: There are various exporters available for Prometheus that allow it to scrape metrics from different types of systems, such as databases, web servers, and more.

Prometheus is often used in conjunction with other tools like Grafana, which provides a graphical interface for querying and visualizing Prometheus data. Together, these tools create a powerful monitoring and observability stack that helps organizations gain insights into the performance and health of their systems.


  • Up and running ubuntu 22.04 LTS machine.
  • Basic knowledge in linux commands.
  • Internet connectivity.

In this post, We will install and configure Prometheus time series database server on ubuntu 22.04 LTS

Step 1: Run System Update

Here are general steps you can follow to install Prometheus on Ubuntu using apt-get:.

To update ubuntu default repository.

sudo apt-get update 

Step 2: Installing Prometheus

Prometheus repository already available in ubuntu 22.04, We need to execute the given command to install Prometheus.

sudo apt-get install prometheus -y

Step 3: Verify Prometheus Service

After installation of Prometheus’s package we need to check the Prometheus service by using given command.

To create main direcory for prometheus.

sudo systemctl status prometheus

By default, Prometheus should be accessible at http://localhost:9090 in your web browser. You can configure Prometheus by editing its configuration file, usually located at /etc/prometheus/prometheus.yml. Make sure to check the official Prometheus documentation for detailed configuration options.

Step 4: Controlling Prometheus Service

To disable on boot.

sudo systemctl disable prometheus

To enable on boot.

sudo systemctl enable prometheus

Start Prometheus Service

sudo systemctl start prometheus

Restart Prometheus Service

sudo systemctl restart prometheus

To stop Prometheus service

sudo systemctl stop prometheus

Step 5: Prometheus Data Path Configuration

In a typical Prometheus installation, the data path refers to the directory where Prometheus stores its time-series data and other related files. The default data directory for Prometheus is specified in the configuration file, usually named prometheus.yml. In the configuration file, you will find a section called storage where the tsdb (time series database) configuration is defined.

Here’s an example snippet from a Prometheus configuration file:

  scrape_interval: 15s

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

    path: /var/lib/prometheus

In this example, the storage.tsdb.path parameter specifies the directory where Prometheus will store its time-series data. In this case, it’s set to /var/lib/prometheus. You can change this path to a location that suits your system and storage requirements.

Make sure that the directory specified in storage.tsdb.path exists and is writable by the user running the Prometheus process. If it doesn’t exist, you may need to create it manually.

Remember to restart Prometheus after making any changes to the configuration file for the changes to take effect:

sudo systemctl restart prometheus.service

Note: The actual configuration file and directory paths may vary based on your installation method and operating system. Always refer to the documentation and configuration files specific to your Prometheus installation for accurate information.

Step 6: Logging Configuration

the log path, or the location where Prometheus writes its logs, is often controlled by the configuration file used to start Prometheus. Prometheus logs can include information about the server’s activity, alerts, and other relevant events.

Here is an example of how you might specify a log file in the Prometheus configuration file:

  scrape_interval: 15s

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

    path: /var/lib/prometheus

    level: info
    format: json
        filename: /var/log/prometheus/prometheus.log

In this example:

  • storage.log.level sets the logging level (info in this case).
  • storage.log.format specifies the log format (json in this case).
  • storage.log.output.file.filename sets the path to the log file (/var/log/prometheus/prometheus.log in this case).

Ensure that the directory specified in storage.log.output.file.filename exists and is writable by the user running the Prometheus process. If it doesn’t exist, create it manually

If you’re running Prometheus as a service, you can also check the systemd service unit file (e.g., /etc/systemd/system/prometheus.service) for information about log paths and options.


We have successfully installed prometheus server on ubuntu 22.04 LTS, If you still have questions, please post them in the comments section below.


Installing Prometheus on Ubuntu 22.04

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top