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 →
- Run a Pushgateway and have each job push on completion with a grouping key such as
jobandinstance.
echo "batch_last_success_timestamp_seconds $(date +%s)" | \
curl --data-binary @- http://pushgateway:9091/metrics/job/nightly_etl/instance/etl-1
- Scrape the gateway with
honor_labels: true. - Push only job-level outcomes (duration, success timestamp, rows processed).
- Delete stale groups when a job is retired, because the gateway keeps them forever.
- For jobs with a lifetime longer than a scrape interval, expose a normal
/metricsinstead.
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.
More on Prometheus and PromQL at Scale
Prometheus memory has grown to 60 GB and keeps climbing. How do you find the cause?IntermediateA developer added `user_id` as a metric label. What is the problem and what do you advise?BeginnerYour dashboard shows the average of per-pod p99 latencies. Why is it wrong, and how do you compute a correct fleet-wide p99?IntermediateChoose histogram bucket boundaries for a service with a 300 ms latency SLO.AdvancedYour EC2 fleet autoscales constantly. How do you keep Prometheus targets up to date?IntermediateYou run 3 Kubernetes clusters. Compare federation, remote_write and Thanos sidecar for a global view.Advanced