talira

Prometheus Pushgateway

Push acceptor for ephemeral and batch jobs

open sourceApache-2.0self-hostablefree

The Pushgateway lets short-lived and batch jobs push their metrics over HTTP, holds them, and exposes them on its own /metrics endpoint for Prometheus to scrape, since such jobs may finish before Prometheus could scrape them. Metrics are grouped by a key of labels starting with job, pushed with a client library's push function or plain curl, replaced or deleted per group, and shown in a small web UI. The Prometheus docs recommend it only for capturing the outcome of service-level batch jobs: it is a metrics cache, not an aggregator or a way to make Prometheus push-based, and machine-level jobs are better served by the Node exporter's textfile collector. It is Apache-2.0 and part of Prometheus, a CNCF project.

Ways to install

Problems it solves

  • my nightly batch job finishes before Prometheus ever scrapes it, so its metrics are lost
  • record when a service-level cleanup job last succeeded and alert if it hasn't run in a day
  • push the number of records a data import processed into Prometheus at the end of the run
  • send a metric from a shell script with curl without running an exporter
  • get metrics from short-lived CI jobs or serverless functions into Prometheus
  • track how long each run of a scheduled ETL pipeline took in Grafana
  • push metrics from a Python or Go batch job using the Prometheus client library
  • delete the metrics a finished job left behind with an API call
  • keep the last pushed values of my batch jobs across restarts of the metrics cache

Features

  • HTTP API to push metrics in the Prometheus text format or protobuf
  • metric groups identified by a grouping key that starts with the job label
  • PUT replaces a group, POST replaces metrics of the same name, DELETE removes a group
  • push_time_seconds and push_failure_time_seconds per group for alerting on stale jobs
  • optional persistence to a file across restarts
  • consistency check on push, which can be turned off for large, frequent pushes
  • admin API to wipe all groups
  • web UI to inspect pushed groups
  • supported by the Prometheus client libraries' push functions

Limitations

  • Doesn't turn Prometheus into a push-based monitoring system: it's meant for service-level batch jobs that can't be scraped45
  • Doesn't aggregate or count across pushes like StatsD: it caches the last metrics each group pushed4
  • Doesn't expire pushed metrics: series stay exposed until deleted through its API, as it has no timeout or TTL45
  • Doesn't give per-instance up monitoring: jobs that push through it lose the up metric Prometheus makes on each scrape5
  • Doesn't keep pushed metrics across restarts by default: persistence needs the --persistence.file flag4

Capabilities

Has an APIplan not known

Alternatives

The same job

These do what Prometheus Pushgateway does.

  1. Node exporter Prometheus exporter for hardware and OS metrics exposed by *NIX kernels
  2. Prometheus The Prometheus monitoring system and time series database
  3. Amazon Managed Service for Prometheus Serverless, Prometheus-compatible monitoring service for container metrics
  4. Cortex Horizontally scalable, highly available, multi-tenant, long term storage solution for Prometheus and OpenTelemetry Metrics
  5. Thanos Open source, highly available Prometheus setup with long term storage capabilities

Compare Prometheus Pushgateway with the top 3