April 24, 2019 · 1 min read · Aizhan Azhybaeva · Updated June 19, 2026

Prometheus Configuration Guide

Prometheus uses command-line flags and YAML configuration files to manage scraping, alerting rules, and storage. Learn how to configure Prometheus for your monitoring stack.

Prometheus Configuration Guide

Prometheus utilizes two configuration methods: command-line flags and configuration files. Command-line flags set immutable system parameters like storage locations and data retention policies, while configuration files manage scraping jobs, instances, and rule file loading.

To access all available command-line options, execute:

./prometheus -h

Runtime Configuration Reloading

Prometheus supports configuration reloading without downtime. Invalid configurations prevent changes from being applied. Reloads are triggered by:

  1. Sending a SIGHUP signal to the process
  2. Posting to the /-/reload endpoint when the --web.enable-lifecycle flag is enabled

Rule files are also reloaded during this process.

Configuration File Format

Specify the configuration file using the --config.file flag. Files use YAML format with optional parameters indicated by brackets. Default values apply to non-list parameters.

The documentation defines generic placeholders for various data types:

  • Boolean values (true/false)
  • Duration strings matching regex patterns
  • Identifiers, strings, and URLs
  • Hostnames with optional ports
  • HTTP/HTTPS protocol specifications
  • Template-expandable strings

Example: Basic Scrape Configuration

global:
  scrape_interval: 15s
  evaluation_interval: 15s

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

  - job_name: 'kubernetes-pods'
    kubernetes_sd_configs:
      - role: pod

A valid example configuration is available in the official Prometheus documentation.

Frequently Asked Questions

How do I reload Prometheus configuration without restarting the server?

Prometheus supports live configuration reloads via two mechanisms: sending a SIGHUP signal to the process, or posting an HTTP request to the /-/reload endpoint (when the --web.enable-lifecycle flag is enabled). Invalid configurations are rejected and the running configuration stays in place, so reloads are safe to trigger at any time.

What is the difference between Prometheus command-line flags and the configuration file?

Command-line flags set immutable system-level parameters — such as storage location and data retention period — that cannot be changed without a restart. The YAML configuration file manages everything else: scrape jobs, targets, alerting rules, and rule file loading, all of which support live reloads.

How do I configure Prometheus to scrape metrics from Kubernetes pods?

Use the kubernetes_sd_configs block in your scrape_configs section with the role set to pod. This tells Prometheus to use the Kubernetes API for service discovery and automatically scrape metrics from pods matching your configuration, without hardcoding individual target addresses.

What scrape interval should I set in Prometheus for a Kubernetes production cluster?

The post's example uses a 15-second scrape interval and evaluation interval, which is a common production starting point. Shorter intervals give finer resolution but increase storage and CPU load; longer intervals reduce overhead but may miss short-lived spikes. Tune based on your alerting latency requirements.

Do I need a separate config file for alerting rules in Prometheus?

Yes — alerting rules are kept in separate rule files referenced from the main prometheus.yaml configuration. When you trigger a configuration reload, Prometheus also reloads these rule files. Keeping rules in dedicated files makes them easier to version-control and review independently from scrape configuration.

Get Started for Free

We would be happy to speak with you and arrange a free consultation with our Kubernetes Expert in Dubai, UAE. 30-minute call, actionable results in days.

Talk to an Expert