1
votes

What would be a good type of Prometheus metric to express revenue (in EUR) generated by an app (business metric)? Each transaction in my app represents an amount of EUR which adds up to total revenue through the app.

I want to graph in Grafana how much money we are making per hour and from how many transactions we've made it. What PromQL formulas should I use?

I am currently using an ever increasing gauge (using Prometheus gauge's inc() function) which gets reset when app re-starts. I am not sure is the best type and I still cannot find a way to show in Grafana how many "EUR/h" we are making.

1

1 Answers

2
votes

First, a disclaimer: Prometheus is not ideal for your use case, unless what you're looking for is ball-park values. Prometheus does not guarantee that all increases will be collected (e.g. just before your service shuts down); new labeled metrics will not account for the first increase (e.g. if your metric first appears with a value of 100, that will be essentially ignored by functions such as rate() or increase()); and finally rate() and increase() use extrapolation at the ends of the time range, so while a 1h estimate will be very close (but not precise), a time range only twice the size of the scrape interval may be off by up to 100%.

Now that we got that out of the way (and we're assuming you're merely interested in a colorful graph approximating your revenue), I'm going to make yet another parenthesis: an ever increasing gauge is (or rather should be) a counter. Prometheus doesn't actually keep track of which metrics are gauges and which are counters, so this is mostly a moot point, but the conceptual difference is important as some Prometheus functions are intended to work with gauges while others are intended to work with counters. E.g. if you imagine the information displayed on a car dashboard, you want to handle a decrease in speed (a gauge) very differently from a decrease in trip distance (a counter) reset or overflow.

With all that out of the way, what you're looking for is a graph panel with the query

increase(my_euros_per_hour_gauge_thats_a_counter[1h])