mailru / graphite-nginx-module

An nginx module for collecting stats into Graphite
135 stars 34 forks source link

Is there a way to get the current aggregate value set by ngx.graphite()? #23

Closed coding-brigadier closed 5 years ago

coding-brigadier commented 6 years ago

Hi.

I ran into a problem where I am trying to collect a number of concurrent requests by emitting some 1s and -1s as part of a request. However, I run into an issue that the data that gets emitted into Grafana ends up being negative due to the fact that the aggregate value gets reset.

Without going too much into detail into the problem, is there a way I can access the current value that is set by ngx.graphite() function?

lomik commented 6 years ago

How about adding new aggregation=gauge with rules:

coding-brigadier commented 6 years ago

I agree with adding something like aggregation=gauge, but keep ngx.graphite as a way to increment and have an API to retrieve the current value. This way we'd have better abstraction.

kirimedia commented 6 years ago

Try v2.4

graphite_param name=my_gauge aggregate=gauge;
ngx.graphite("my_gauge", 1)
ngx.graphite("my_gauge", -1)
local value = ngx.graphite.get("my_gauge")
ngx.graphite.set("my_gauge", 10)
coding-brigadier commented 6 years ago

Can you give me a quick overview on how the gauge value gets emitted if there is no interval? Or is the idea to use the gauge as a buffer from which we can grab and append it to the other aggr?

kirimedia commented 6 years ago

First the parameter value is 0. With the ngx.graphite, you can send a delta to which the value will change. And this value will be stored all the time the server is running. You can only change the value of the parameters with agr = gauge