How to Install and Configure Prometheus: A Step-by-Step Guide

This easy-to-follow tutorial will help you set up and configure Prometheus so you can start monitoring your computer systems and applications right away.

Prometheus

Introduction to System Monitoring

Linux | macOS | Windows

Understanding Prometheus

Prometheus is a popular, open-source tool used to monitor computers, servers, and software applications. It works by collecting data, called "metrics," from your systems at regular times. These metrics can tell you how healthy your system is, like how much memory is being used or if a server is running too slowly. Because it was built to handle a lot of data quickly, it is a favorite choice for many big tech companies.

Unlike some older monitoring tools that wait for systems to send them data, Prometheus actively goes out and pulls the data itself. It connects to special addresses on your servers, grabs the latest health numbers, and stores them in its own fast database. This "pull" method makes it very reliable and easy to set up, especially when you have many different pieces of software running at the same time.

Another great feature of Prometheus is how you can use the data once it is collected. It comes with a smart search language called PromQL, which lets you ask detailed questions about your system's past and present performance. You can use this data to create beautiful charts, spot problems before they cause crashes, and even set up alarms that send you a message if something stops working correctly.

Prerequisites

  • A computer or virtual machine running a modern operating system like Linux, macOS, or Windows.
  • A basic understanding of using the command-line interface (terminal).
  • Internet access to download the required software packages.
  • Administrator or root privileges on your machine to extract and run the files.

Step-by-Step Installation and Configuration

1

Download and Extract Prometheus

First, you need to download the latest release of Prometheus for your platform. Once downloaded, extract the compressed file and navigate into the newly created directory using your terminal.
BASH
tar xvfz prometheus-*.tar.gz
cd prometheus-*
2

Configure Prometheus

Before starting Prometheus, you must give it instructions on what to monitor. Create a new text file named prometheus.yml in your current directory and add the following basic configuration code. This tells Prometheus to monitor itself.
BASH
global:
  scrape_interval: 15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']
3

Start the Prometheus Server

To start Prometheus using your newly created configuration file, run the following command from the directory containing the extracted Prometheus binary file:
BASH
# Start Prometheus.
# By default, Prometheus stores its database in ./data (flag --storage.tsdb.path).
./prometheus --config.file=prometheus.yml
4

Verify the Installation

Once started, Prometheus will begin collecting data. You can verify it is running properly by opening your web browser and visiting the following addresses:
  • Status Page: Go to http://localhost:9090 to see the Prometheus dashboard.
  • Raw Metrics: Go to http://localhost:9090/metrics to see the actual raw data Prometheus is collecting about itself.

Discover CTCservers Dedicated Server Locations

CTCservers servers are available around the world, providing diverse options for hosting websites. Each region offers unique advantages, making it easier to choose a location that best suits your specific hosting needs.