Interview Prep/Monitoring & Observability/Prometheus and PromQL at Scale

You have 500 short-lived batch jobs that finish before Prometheus can scrape them. How do you capture their metrics?

IntermediateScenarioPrometheus and PromQL at Scale
Answer

Situation read → Pull-based scraping misses jobs that live for seconds. This is the intended use case for the Pushgateway.

What I'd do →

  1. Run a Pushgateway and have each job push on completion with a grouping key such as job and instance.
echo "batch_last_success_timestamp_seconds $(date +%s)" | \
  curl --data-binary @- http://pushgateway:9091/metrics/job/nightly_etl/instance/etl-1
  1. Scrape the gateway with honor_labels: true.
  2. Push only job-level outcomes (duration, success timestamp, rows processed).
  3. Delete stale groups when a job is retired, because the gateway keeps them forever.
  4. For jobs with a lifetime longer than a scrape interval, expose a normal /metrics instead.

Why → The Pushgateway is a metric cache for batch results, not a general push path.

Interview tip → Know its drawbacks: single point of failure, no up health signal per job, stale data.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus and PromQL at Scale