Prometheus: Reload Without Restart
A reload is Prometheus reading its config file again while it keeps running. No restart means no gap in the scraped data.
Add a target to the config file
A new scrape job points at the same ShopSentry process. Save the file first, then reload.
cat >> prometheus.yml <<'EOF'
- job_name: shopsentry-second
static_configs:
- targets: ['127.0.0.1:18105']
EOFCheck the config before reloading
Promtool reads the file without starting anything. Fix errors here, not after a reload.
promtool check config prometheus.ymlSend the reload
A successful reload answers with an empty body. No output is the good news here.
curl -s -X POST http://127.0.0.1:19105/-/reload; echo "reload-exit $?"Example
curl -s "http://127.0.0.1:19105/api/v1/query?query=up%7Bjob%3D%22shopsentry-second%22%7D"Key points
- Reload: Prometheus re-reads prometheus.yml and its rule files without stopping.
- The reload endpoint is POST /-/reload on the Prometheus web server.
- The endpoint only works when Prometheus starts with the --web.enable-lifecycle flag.
- Without the flag, the same POST returns an error and nothing changes.
- A reload that finds a broken config is rejected and the old config keeps running.
- SIGHUP is the other way to reload, by sending the hang-up signal to the process.
- A restart drops in-flight scrapes, while a reload keeps every scrape on schedule.
- Check the new target in the Targets page after a reload, not just the empty reply.
In this example, the new job shopsentry-second answers up as 1 after the reload, with no restart in between. Prometheus picked up the new target from the edited file while the old jobs kept scraping. A reload with a broken config would have answered with an error instead, and the old config would have kept running.
Note
Reload changes the config, not the data. Old samples stay exactly where they were.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
You add a scrape target to prometheus.yml. What is the fastest way to make Prometheus use it without losing samples?