qnikst / prometheus-haskell

Haskell client library for exposing prometheus.io metrics.
7 stars 1 forks source link

Introduce metrics for gathering stat in a window. #9

Open qnikst opened 4 years ago

qnikst commented 4 years ago

With prometheus design it's not easy to measure intermediate values for gauges. Assume we have a resource pool and we want to see how many connections were used at once in a moment. Using simple Gauge we may see current value, but that tells nothing about want had happened using scrapes. If we keep two counters for allocated and for deallocated connections we can estimate that value, but it's not precise. So I want to implement a special gauge that will keep two values: maximum in the window and current value, and additional method that sets maximum to the current value. Then we can keep some windows and track maximum value there.

With such approach it's possible not to keep only maximum but any value, like percentile or moving average.

qnikst commented 4 years ago

Implemented in prometheus-client-extra it work fine in production, but there are some unsolved problems for example if it's possible to effectively use other functions than a maximum.