Search code examples
jmxgrafanagraphitespring-boot-actuatorcodahale-metrics

Log data into grafana for every minute


The below code registers five metrics count, oneminuteRate, fiftenMinuteRate, fiveMinuteRate, meanRate into graphite for every 30 seconds from my application.

public void collectMetric(string metricName, long metricValue){
        mr.meter(metricName).mark(value)
    }

I would like to show in the Grafana dashboard the no of requests that are received every minute.(i,e if in the first minute 60 is received, in the second minute 120 is received) Since the count in the meter metric above just keeps increasing and all the *Rate values are events per second. I am not sure how to log metric into Grafana dashboard that displays the no of requests received per minute. Any advice is highly appreciated?

Suppose if I use mr.counter(metricName).inc(value) IS there a way to reset the counters every 1 minute?


Solution

  • I had the same problem. The way that I found is that I resolved this in Grafana. When you're on the panel's metrics, you can add a function to your query like this:

    Screenshot

    You can try the derivative() function or perSecond() function but these functions are not completly reliable, it depends what you're doing with these in your panel. But with these you'll see the number of input in time and not the total.