Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropwizard metrics - How to reset counters after reporting interval

I am using codahale metrics (now dropwizard metrics) to monitor a few 'events' happening in my system. I am using the counters metrics to keep track of number of time the 'event' happened.

I checked the values printed by the reporter for my counter metrics and it seems like the value keeps on increasing (and never goes down). This seems logical as I am always using metrics.inc() function whenever my 'event' occurs.

What I really want is to get count of my 'event' happening between two reporting times, for this I need to reset my counter every time I report my metrics, but I couldn't find any option in counter metrics to do that. Is there a way or general practice followed by codahale users to produce such metrics?

Current Behavior (reporting time 10 sec):

00:00:00 0
00:00:10 2 // event happened twice
00:00:20 2 // event did not occur
00:00:30 5 // event occured three times`

Expected metrics:

00:00:00 0
00:00:10 2
00:00:20 0
00:00:30 3
like image 420
face Avatar asked Jun 30 '16 20:06

face


1 Answers

To sum up or calculate count(total) per arbitrary interval:

hitcount(perSecond(your.count), '1day')

Afaik it does all the black magic inside. Including but not limited to summarize(scaleToSeconds(nonNegativeDerivative(your.count),1), '1day') and also there should be scaling according to carbon's retention periods (one or many) that fall into chosen aggregation interval.

like image 170
Sasha Avatar answered Oct 25 '22 08:10

Sasha