7

I am configuring Prometheus to access Spring boot metrics data. For some of the metrics, Prometheus's pull mechanism is ok, but for some custom metrics I prefer push based mechanism.

Does Prometheus allow to push metrics data?

Mandroid
  • 6,200
  • 12
  • 64
  • 134

3 Answers3

8

No. Prometheus is very opinionated, and one of it's design decisions is to dis-allow push as a mechanism into Prometheus itself.

The way around this is to push into an intermediate store and allow Prometheus to scrape data from there. This isn't fun and there are considerations on how quickly you want to drain your data and how pass data into Prometheus with time-stamps -- I've had to override the Prometheus client library for this.

https://github.com/prometheus/pushgateway

Prometheus provides its own collector above which looks like it would be what you want but it has weird semantics around when it expires pushed metrics (it never does, only overwrites their value for a new datapoint with the same labels).

They make it very clear that they don't want it used for pushed metrics.

All in all, you can hack something together to get something close to push events. But you're much better off embracing the pull model than fighting it.

Saurabh Maurya
  • 870
  • 7
  • 12
  • 3
    That is sad as serverless and Function As A Service become more popular now. Pushing custom metrics from lambdas is a pain with Prometheus. – zenbeni Jan 13 '21 at 09:51
  • The real target would be to push custom metrics to a cache to keep the pulling model. The best solution I can see in the future would be using a timeseries datastore that is automatically connected to prometheus. AWS seems to want to do that with TimeStream & Prometheus (their managed service). https://www.zdnet.com/article/amazon-timestream-database-is-now-generally-available/ – zenbeni Jan 13 '21 at 10:02
4

Prometheus has added support for the push model recently. It is called as remote write receiver.

Link: https://prometheus.io/docs/prometheus/latest/querying/api/#remote-write-receiver

From what I understand it only accepts POST request with protocol buffers and snappy compression.

amolgautam
  • 897
  • 10
  • 20
1

Prometheus doesn't support push model. If you need Prometheus-like monitoring system, which supports both pull model and push model, then try VictoriaMetrics - the project I work on:

  • It supports scraping of Prometheus metrics - see these docs.
  • It supports data ingestion (aka push model) in Prometheus text exposition format - see these docs.
  • It supports other popular data ingestion formats such as InfluxDB line protocol, Graphite, OpenTSDB, DataDog, CSV and JSON - see these docs.

Additionally to this VictoriaMetrics provides Prometheus querying API and PromQL-like query language - MetricsQL, so it can be used as a drop-in replacement for Prometheus in most cases.

valyala
  • 11,669
  • 1
  • 59
  • 62