How to Install Prometheus on Windows, Linux, and macOS

Balaji SomasaleBalaji Somasale
3 min read

Prometheus is a powerful open-source monitoring and alerting toolkit that is highly extensible and widely used for monitoring applications, systems, and network infrastructure. This guide will walk you through the steps to install Prometheus on Windows, Linux, and macOS.

Prerequisites

Before installing Prometheus, ensure you have the following:

  • Admin or root privileges to install software and configure services.

  • Basic knowledge of the command line.

Installation on Windows

  1. Download Prometheus:

  2. Extract the ZIP file:

    • Right-click the downloaded .zip file and select "Extract All".

    • Choose a destination folder to extract the contents.

  3. Run Prometheus:

    • Open a Command Prompt or PowerShell window.

    • Navigate to the folder where you extracted Prometheus.

    • Run the following command to start Prometheus:

        prometheus.exe --config.file=prometheus.yml
      
    • Prometheus will start, and you can access the web interface at http://localhost:9090.

Installation on Linux

  1. Download Prometheus:

    • Open a terminal.

    • Download the latest Prometheus tarball with wget:

        wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz
      
  2. Extract the Tarball:

    • Extract the tarball using tar:

        tar xvfz prometheus-2.34.0.linux-amd64.tar.gz
      
  3. Move Prometheus Binaries:

    • Move the Prometheus binaries to a directory in your PATH (e.g., /usr/local/bin):

        sudo mv prometheus-2.34.0.linux-amd64/prometheus /usr/local/bin/
        sudo mv prometheus-2.34.0.linux-amd64/promtool /usr/local/bin/
      
  4. Run Prometheus:

    • Navigate to the directory where you extracted Prometheus:

        cd prometheus-2.34.0.linux-amd64
      
    • Start Prometheus:

        ./prometheus --config.file=prometheus.yml
      
    • Prometheus will start, and you can access the web interface at http://localhost:9090.

Installation on macOS

  1. Download Prometheus:

    • Open a terminal.

    • Use wget or curl to download the latest Prometheus tarball:

        wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.darwin-amd64.tar.gz
      

      or

        curl -LO https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.darwin-amd64.tar.gz
      
  2. Extract the Tarball:

    • Extract the tarball using tar:

        tar xvfz prometheus-2.34.0.darwin-amd64.tar.gz
      
  3. Move Prometheus Binaries:

    • Move the Prometheus binaries to a directory in your PATH (e.g., /usr/local/bin):

        sudo mv prometheus-2.34.0.darwin-amd64/prometheus /usr/local/bin/
        sudo mv prometheus-2.34.0.darwin-amd64/promtool /usr/local/bin/
      
  4. Run Prometheus:

    • Navigate to the directory where you extracted Prometheus:

        cd prometheus-2.34.0.darwin-amd64
      
    • Start Prometheus:

        ./prometheus --config.file=prometheus.yml
      
    • Prometheus will start, and you can access the web interface at http://localhost:9090.

Configuring Prometheus

Prometheus uses a configuration file, prometheus.yml, which is located in the extracted directory. This file contains all the settings and configurations for scraping targets, alerting rules, and more. You can customize this file according to your monitoring requirements. Here's a basic example of what prometheus.yml might look like:

global:
  scrape_interval: 15s # By default, scrape targets every 15 seconds.

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

Conclusion

With Prometheus installed on your system, you now have a robust tool for monitoring and alerting. Whether you're on Windows, Linux, or macOS, the installation process is straightforward, and you can start configuring Prometheus to meet your specific monitoring needs. As you grow more familiar with Prometheus, you'll discover its powerful features and how it can help you maintain and optimize your systems effectively.

0
Subscribe to my newsletter

Read articles from Balaji Somasale directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Balaji Somasale
Balaji Somasale

Tech Enthusiast