/etc/prometheus/prometheus.yml.
Below are concise examples and explanations of the most common configuration options you’ll use.
Basic example
A minimal configuration that scrapes Prometheus itself:Key sections
- global: Default parameters applied to all scrape jobs unless overridden.
- scrape_configs: Defines scrape jobs (a job is a collection of instances) and how to scrape them.
- static_configs.targets: A simple list of
host:porttargets to scrape.
Common configuration fields (per job)
Example configuration that overrides some global settings for a specific job:Field summary table
Note: Keep
scrape_timeout shorter than or equal to scrape_interval. Timeouts longer than the interval are usually not useful.
Prometheus configuration can also include additional sections such as alerting, rule_files, remote_read, remote_write, and storage. Use rule_files to store recording and alerting rules.
Example: custom metrics path and multiple targets
Add a new job to your Prometheus config
- Open the configuration file:
- Add a new job under
scrape_configs. Minimal example:
- Save the file.
Validate and reload configuration
Prometheus does not automatically pick up YAML changes. First validate the file to catch syntax problems:- HTTP reload endpoint (recommended): ask Prometheus to reload configuration without restarting:
- Graceful reload by sending a signal to the process:
pidof prometheus or pgrep prometheus. When Prometheus is managed by systemd, using signals may be less reliable.
- Restart the systemd service:
systemctl reload prometheus for a graceful reload if the unit file allows it. Use the service name your system provides.
If you run Prometheus in the foreground (for example,
./prometheus), stopping it with Ctrl+C and starting it again will apply the new configuration. For systemd-managed instances, prefer systemctl restart prometheus or the HTTP reload endpoint.Verify targets in the Prometheus UI
- Open the Prometheus UI (default:
http://localhost:9090). - Navigate to Status → Targets. This page shows configured targets and their current scrape status.
- Query the
upmetric to check target health. Examples:
1 means the target is up and being scraped; 0 means it is down.
Troubleshooting tips
- If a target shows as DOWN on the Targets page:
- Confirm the exporter is running and listening on the expected
host:port. - Test connectivity locally with
curl http://<host>:<port><metrics_path>. - Check Prometheus server logs for scrape errors.
- Confirm the exporter is running and listening on the expected
- If
promtool check configfails, fix YAML formatting and re-run the tool before reloading. - When using
basic_author TLS, verify certificates and credentials match the exporter configuration.
Summary
- Define targets and jobs in
/etc/prometheus/prometheus.yml. - Use
scrape_interval,scrape_timeout,metrics_path, andschemeto control scraping behavior. - Validate changes with
promtool check configand reload Prometheus using the HTTP reload endpoint, SIGHUP, orsystemctl restart/reload. - Confirm scrapes via the Prometheus web UI (Status → Targets) or by querying the
upmetric.
Links and references
- Prometheus documentation: https://prometheus.io/docs/
- Prometheus configuration reference: https://prometheus.io/docs/prometheus/latest/configuration/configuration/