On Thursday, 17 March 2022 at 10:28:18 UTC [email protected] wrote: > I work as SRE at a company which runs Ruby on Rails application deployed > with Unicorn. Not so long time ago, we started to migrate from StatsD ( > https://github.com/statsd/statsd) based metrics to Prometheus. We wrote > wrapper library which uses > https://gitlab.com/gitlab-org/prometheus-client-mmap (which also is fork > of https://github.com/prometheus/client_ruby) and so far so good, > everything went as planned during PoC. > > But recently we found some limitation which we are banging head on how to > solve. Many people are used to StatD and in application code they used just > to increase gauges values (from multiple locations) and aggregating such > values gives you "current" value. > > Now with Prometheus, we have multiple muti-thread workers which updates > their own gauge values (workers are labeled e.g. with id). So let's say one > process stores 10 in gauge and after some minutes another worker stores 5. > How we shall know what value is the latest? >
What do you want to happen? Do you want the scraped result to be 15? In that case it's a counter not a gauge, and you need to add to it. Or do you want two separate timeseries showing values 5 and 10? Then you need separate gauges in each thread with their own labels. > > Maybe someone had similar issues and come up with some different solutions? > There is statsd_exporter <https://github.com/prometheus/statsd_exporter>, which takes the same protocol messages as statsd, but exposes gauges and counters for scraping. This is an easy way to aggregate counters across multiple processes and/or threads, since update messages from multiple sources can update the same counter, and it doesn't matter whether they are separate processes or threads. I suspect it means you'll have to revert your code back to using statsd client though :-) -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/0e91e48c-3462-468e-9bf2-e6ca2118fa25n%40googlegroups.com.

