yty
yty

Reputation: 543

How to expose non-realtime metrics to Prometheus

I'm instrumenting an exporter, using Java client, that will expose metrics that potentially have been sitting in the buffer for a while to Prometheus. Each metric comes with a timestamp, so I know exactly when the metric was collected. However, I'm having a hard time using timestamp when constructing metrics, even though Collector.MetricFamilySamples.Sample class has a timestampMs field. This is especially hard for quantile metrics like Summary or Histogram. I can pass the metric value to it using Summary.observe(), but I can't also pass in a timestamp indicating the time of observation.

What's the right way to do this, please? Thanks!

Upvotes: 0

Views: 1346

Answers (1)

brian-brazil
brian-brazil

Reputation: 34172

Prometheus isn't designed for this. The best thing to do would be to report the metric before it enters the buffer. Failing that, I'd suggest reporting the metrics as-is without timestamps, and living with the varying lag.

Upvotes: 1

Related Questions