Wednesday, October 21, 2015

Monitoring Java based Applications: Metrics+Graphite+Grafana

As developers when we write a piece of code we try our best to make sure we have carefully chosen the best algorithms, the data structures are carefully tuned to match the situation at hand and the piece of software we wrote just works out of the box. Unfortunately life is not ideal and there are some hiccups that are bound to hit us however smooth the ride be. Some nasty bugs will inevitably show up on the production server as the software is used for a length of time. The best one can do then is to monitor the software being used in production environment, anticipate the problems before it hits the user and hampers their experience.

This post will talk about such a stack for monitoring java based applications involving:

We will use dropwizard metrics to instrument our Java code and push the data to graphite. Graphite will store our time-series data meaning values such as latency, performance, throughput, counts etc corresponding to say our APIs. Though Graphite renders graphs built on top of the time-series data as and when required, Graphite on its own doesn't provide the best visual experience and dashboard properties. We will thence use Grafana to build and view our dashboards. So the pipeline on a high level will be this:

Here is the documentation of dropwizard metrics listing its various capabilities. Their documentation is not that great, in my opinion, but workable. The good news is there is also a spring library that provides annotations you can use directly to enable instrumentation. Just add an annotation on top of a method and thats it. Here is an example:

@Metered(absolute = true, name= "RuntimeError")
public ErrorMessage handleThrowable(HttpServletRequest request, Throwable t) {



As you see here, there is an annotation (@Metred) which is responsible for instrumenting the following method- handleThrowable(...). The metred annotation gives the timed average meaning number of errors in a unit of time. As simple as that! The code in bold is all you need to write to instrument the following method, for instance.

Next, we need to tell our metrics where Graphite resides so data can be sent to Graphite. Here is how you configure this. The prefixedWith() attribute defines how Graphite will show this. Here is a screenshot from my Graphite dashboard showing the tree-based structure that we just set.


On the right of this pane shown above you ca see the graph you select. The visual features in Graphite is rather limited so we will forward the Graphit input to Grafana. Here is a video introducing Grafana interface.e

Make your dashboards the way you wish to see your graphs and keep monitoring to stay ahead of the bugs!


  1. Great work, I’m happy that I came across with your site this article is on point,thanks again and have a great day. Keep update more information..

    Android Training in Chennai

  2. I agree with your thoughts!!! As the demand of java programming application keeps on increasing, there is massive demand for java professionals in software development industries. Thus, taking training will assist students to be skilled java developers in leading MNCs.Best Java Training in Chennai | JAVATraining Institutes in Chennai

  3. Hi Dude,
    Awesome Post!!! With unique content, I really get interest to read this post. I hope this article help many of them who looking this pretty information.
    Hadoop Training in Chennai|Big Data Training Chennai|Best Hadoop Training in Chennai


  4. Great and useful article. Creating content regularly is very tough. Your points are motivated me to move on.

    SEO Company in Chennai

  5. Great explanation to given on this post .The given information very impressed for me really so nice content.

    DotNet Training in Chennai Mylapore

  6. Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training

  7. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai Java Training in Chennai

    Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training in Chennai

  8. Hi, Really your post was very informative. Today's internet era learn Hadoop Online Training will helps you to reach your goal.Selenium Training

  9. Excellent articles and really interesting.I read that our blog very nice.We'll give all example code excellent and then easy observe the all useful information.Selenium Training Chennai | Selenium Training in Chennai

  10. I get a lot of great information from your blog. Thank you for your sharing this informative blog. I have bookmarked this page for my future reference.
    Selenium Training in Chennai

  11. Hi, I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog.R Programming Online Training

  12. Thank you for Sharing.(ERP) Enterprise Resource Planning Software Solutions in Chennai.
    ERP Software Company Chennai | ERP Software Development Chennai

  13. Thank you for this valuable information. I have got some important suggestions from it. Get your business to the next level in simple steps.
    ERP Solutions in Chennai | ERP Software Solutions in Chennai.

  14. There was very wonderful information and that's great one. I really appreciate the kind words, thanks for sharing that valuable information.
    Graphic design course in chennai

  15. very usefull informatation.and iam expecting more posts like this please keep updating us........

  16. Nice blog with smart content., The explanation of java concept was so informative. Thanks for sharing such a nice blog. Java Training in Chennai | Dot Net Training in Chennai

  17. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog. Selenium Training Institute in Chennai | ISTQB Training Institute in Chennai | Six Sigma Certification Training in Chennai

  18. I would like to say thank you for the amazing details and concepts you are sharing in this.
    Webseiten Gestaltung Lüdenscheid

  19. Fantastic Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog.
    Mat Lab Project Center in Chennai | Embedded Project Center in Chennai | IEEE Project Center in Chennai | Final Year Project Center in Chennai

  20. The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .
    office 2010 professional plus key deutsch

  21. Sap Training Institute in Noida-Webtrackker is the exceptional SAP training center in noida. SAP or systems software and products in facts processing are an extraordinary a part of ERP or organization aid planning. ERP is an integration of several software or packages this is used to streamline the techniques of a big scale enterprise or business. ERP has been essential parts of enterprise organization way manipulate and one of the principal structures of ERP has been SAP.
    Sas Training Institute in Noida
    PHP Training Institute in Noida
    Hadoop Training Institute in Noida
    Oracle Training Institute in Noida
    Linux Training Institute in Noida
    Dot net Training Institute in Noida
    Salesforce training institute in noida
    Java training institute in noida

  22. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    online marketing lüdenscheid

  23. Australia best tutor is well known academic portal. Here students can get different kind of Online Assignment help services like that

    1.Online Assignment Help
    2.Instant Assignment Help
    3.Assignment Help
    4.Help with Assignment assignment Help

    And also access that services at any time and any where.

  24. Air conditioning maintenance birmingham- onlyrepaircenter has the 30 Years Experience in Air conditioning maintenance service in birmingham. If you are facing the problem in your air conditioning of any company such as Daikin, Mitsubishi, Carrier, Fujitsu, Toshiba, Airedale, Sanyo, Trane and LG then you can contact to us.

    Air Conditioning Installation birmingham,
    Commercial air conditioning repair Birmingham,
    residential air conditioning repair birmingham ,
    Air Conditioning Maintenance birmingham ,
    window ac repair birmingham,

  25. I really enjoyed while reading your article. The information you have delivered in this post was damn good. Keep sharing your post with efficient news.
    MSC Project Center in Chennai | MSC Project Center in Velachery

  26. very usefull informatation.and iam expecting more posts like this please keep updating us.......
    Selenium Training in Chennai
    Oracle Training in Chennai

  27. I really enjoyed while reading your article, the information you have delivered in this post was damn good. Keep sharing your post with efficient news.. Automation Anywhere Training in Chennai | RPA Training Institute in Chennai | UI Path Training Institute in Chennai