
/metrics endpoint on the configured schedule. Prometheus does not need to know that the metrics were pushed; it only consumes the metrics that the Pushgateway exposes.
Typical push flow:
- The job collects metrics while running.
- Before exiting, the job pushes those metrics to the Pushgateway.
- The Pushgateway stores and serves those metrics at
/metrics. - Prometheus scrapes the Pushgateway at its regular scrape interval.
- Capture metrics from non-long-lived processes (batch jobs, one-off tasks).
- Decouple metric lifetime from job lifetime so Prometheus can scrape them at its schedule.
- Add grouping labels to distinguish pushes from multiple instances.
Example: push a local metrics file to the Pushgateway
Use the Pushgateway primarily for short-lived, ephemeral jobs. The Pushgateway stores metrics until they are explicitly deleted or overwritten. If metrics are not removed or updated after a job completes, they can become stale and produce misleading results in Prometheus.
- Prefer instrumenting long-lived services directly and let Prometheus scrape them.
- Use meaningful grouping labels in the URL path to avoid label collisions and to identify metric sources.
- Automate deletion of Pushgateway entries when jobs are complete, or implement a TTL/cleanup mechanism if appropriate.
- Monitor the Pushgateway itself as a scrape target to ensure it remains available for Prometheus to collect pushed metrics.