Skip to content

Install Prometheus: Configuration, Targets & Scraping

DodaTech 4 min read

In this tutorial, you'll learn about Install Prometheus: Configuration, Targets & Scraping. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Installing Prometheus involves downloading the server binary, configuring scrape targets in the YAML configuration file, and starting the service to begin collecting metrics from your infrastructure.

What You'll Learn

In this tutorial, you will install Prometheus from scratch, write a configuration file with multiple scrape targets, and verify metrics collection through the web UI and command line.

Why It Matters

A correct installation is the foundation of every monitoring system. Misconfigured scrape targets, wrong intervals, or missing relabeling rules lead to gaps in data and blind spots in your Observability. Getting the install and configuration right ensures reliable metrics from day one.

Real-World Use

The DodaZIP file compression service runs Prometheus on every build server to collect CPU, memory, and disk metrics. Each server is configured as a scrape target in the main Prometheus config, and the operations team validates new server additions by checking the targets page before routing production traffic.

Step 1: Download Prometheus

Download the latest Prometheus release from the official website. Extract the archive and move the binaries to a system directory:

wget https://github.com/prometheus/prometheus/releases/download/v2.53.0/prometheus-2.53.0.linux-amd64.tar.gz
tar xvf prometheus-2.53.0.linux-amd64.tar.gz
sudo mv prometheus-2.53.0.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-2.53.0.linux-amd64/promtool /usr/local/bin/

Expected output:

prometheus-2.53.0.linux-amd64.tar.gz
prometheus-2.53.0.linux-amd64/
prometheus-2.53.0.linux-amd64/prometheus
prometheus-2.53.0.linux-amd64/promtool

Step 2: Create Configuration File

Create a <a href="/devops/prometheus-grafana/">Prometheus</a>.yml configuration file. This file defines global settings, scrape intervals, and specific targets:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets:
          - localhost:9090

  - job_name: node
    static_configs:
      - targets:
          - localhost:9100

The scrape_interval tells Prometheus how often to collect metrics. The scrape_configs section lists each job and its targets.

Step 3: Start Prometheus

Start the Prometheus server with your configuration file:

prometheus --config.file=prometheus.yml

Expected output:

ts=2026-06-21T10:00:00.000Z caller=main.go:548 level=info msg="Starting Prometheus" version=2.53.0
ts=2026-06-21T10:00:00.000Z caller=main.go:553 level=info msg="Build context" builder=...
ts=2026-06-21T10:00:00.000Z caller=web.go:575 level=info msg="Listening on" address=0.0.0.0:9090

Step 4: Verify the Web UI

Open a browser and navigate to http://localhost:9090. The Prometheus web UI shows an expression browser, the targets page at /targets, and the configuration at /config.

Check the targets page to confirm all targets are UP. Each target shows the last scrape time, scrape duration, and any errors.

Step 5: Add More Targets

To monitor additional services, add more jobs to the scrape_configs section:

scrape_configs:
  - job_name: web-app
    scrape_interval: 10s
    static_configs:
      - targets:
          - app-server:8080
          - app-server:8081

  - job_name: database
    static_configs:
      - targets:
          - db-server:9187

Reload the configuration by sending a SIGHUP signal or restarting Prometheus without downtime using the reload endpoint.

Common Mistakes

1. Firewall Blocking Scrapes

Prometheus scrapes targets by connecting to their HTTP endpoints. Ensure the target port is reachable from the Prometheus server and not blocked by a firewall.

2. Wrong Metric Path

By default Prometheus scrapes /metrics. If your target exposes metrics at a different path, use the metrics_path parameter in the job config.

3. Missing relabel_configs

Relabeling rules let you add, remove, or modify labels before ingestion. Forgetting them can result in missing metadata needed for alerting rules.

4. Scrape Interval Too Short

Setting scrape_interval below 5 seconds on many targets generates excessive load. Start with 15 seconds and adjust based on your metrics volume.

5. Not Running as a Service

Running Prometheus in a terminal session means it stops when you log out. Set up a systemd service or use a Process manager to ensure Prometheus runs continuously.

Practice Questions

1. How do you add a new scrape target to Prometheus? Add a new entry under scrape_configs in <a href="/devops/prometheus-grafana/">Prometheus</a>.yml with the target address and restart or reload Prometheus.

2. What does the scrape_interval setting control? It controls how often Prometheus collects metrics from each target. The default is 1 minute, but 15 seconds is common for production.

3. How can you verify that Prometheus is scraping a target successfully? Check the targets page at /targets in the Prometheus web UI. Targets with state UP are scraping successfully.

4. What happens if a target is unreachable during a scrape? Prometheus records the scrape as failed and retries on the next interval. The metric up{job="...", instance="..."} returns 0 for failed targets.

5. Challenge: Write a configuration that scrapes three different services, each with a different scrape interval, and verify all targets show as UP.

What's Next

Learn PromQL to query the collected metrics, then set up alerting rules to get notified when things go wrong.

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro