Monitoring metrics with Netflix Servo

Developing a metrics monitoring component seems simple, but deceptively so.

While adding a simple counter component is easy enough, more advanced functionalities (polling, filtering, exporting the results… ) are somewhat trickier to code. Also since the metrics must be read and written in parallel with the core application logic, the code will be multithreaded, which adds another challenge: concurrency is hard.

So an in-house solution is doable, but will probably take at least a few days to develop, and that’s assuming it’s bug free.

The alternative is to re-use existing libraries which neatly solve this problem by providing monitoring components such as counter, gauges, timers, and the ability to export the data via JMX. For instance:

Netflix servo
DropWizard metrics

Example: the java code below calculates as many prime numbers as possible for a specified period of time, and uses Servo’s counter and peak rate counter to keep track of the total number of primes discovered, and the maximum rate of primes discovered per second.

The metrics are automatically exposed via JMX so Java Mission Control can pick it up:


…and chart the resulting data.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s