A scrape config Prometheus will actually load
Prometheus is only as useful as its prometheus.yml, and a single mis-indented line can stop the whole server starting. This builder produces a valid config from a form: global intervals, an Alertmanager target, rule-file globs, and as many scrape jobs as you need — each with its own path, scheme, and target list.
How it works
The output follows Prometheus’ configuration schema. The global block sets scrape_interval and evaluation_interval. An optional alerting block lists Alertmanager endpoints under static_configs, and rule_files holds your alert and recording-rule globs. Under scrape_configs, each job emits a job_name, an optional metrics_path (only when it differs from the default /metrics), an optional scheme for HTTPS, an optional per-job scrape_interval, and a static_configs targets list parsed from your comma- or space-separated entries. Proper two-space YAML indentation is handled for you so the file loads on first try.
Tips and example
- Always include a job that scrapes Prometheus itself (
localhost:9090) so you can monitor the monitor. - Use a per-job
scrape_intervalfor heavy exporters — scraping a slow endpoint every 15 seconds can overload it. - Keep alert and recording rules out of this file and in the globs under
rule_files; that separation keeps the config readable. - Validate the result with
promtool check config prometheus.ymlbefore reloading in production.