Cloud Strategy, Practical examples

Adding new relic observability to Java (micro)services

January 6, 2021

Our old monolithic applications used to be very simple and keeping everything at our sight was very easy. We had one or two databases, one or more app servers, and that’s it! Everything ready to turn into chaos. Modern architecture patterns have one big tradeoff, which is they require a plethora of components and that increases the difficulty to keep eyes over such a big environment.

For that reason, plugging in applications that will help us with the observability, and even developing our own tools is needed so we can understand what is going on with our apps. Otherwise we can easily fall into a rabbit hole looking for all the edges to see which one has the root problem causing our clients to slow down.

The Market Options

Talking about tools, I did compare Dynatrace, New Relic, Elastic and Splunk. For Now, New Relic is the chosen one simply due to budget. Elastic seems to lack some features and is speeding up. Splunk, Dynatrace and New Relic’s AI powered features are amazing.

Adding New Relic to your microservice

In this article I’m gonna cover the addition of New Relic observability to Java microservives.

  1. Create your free account and grab your account Id – The free account will allow you to upload up to 100gb of data per month.
  2. Then you’ll need the yaml with configurations for your account and app:
    • Once you are logged in click on “APM” on the top bar, then click “Add more on the top right area”. This is gonna open a tab with several options. Just click Java and you will see somthing like this:
  3. Also use the command with black background to download the new relic jav you’re gonna need in a step beyond.
  4. Once you have downloaded the zip file, unzip it and grab the newrelic.jar
  5. Finally, place the generated yaml file along with the jar in a folder that is accessible by your project
  6. At last, change your dockerfile to include the -javaagent command

PS: in this example I’m adding a specific version of the newrelic jar. For production purposes, I recommend storing the jar in your own library server, such as Nexus or Jfrog.

Watching your app

Minutes after deploying your pod, you’ll be able to login to New Relic and start seeing the dashboards built for your application.

Important metrics that can be seen right without any additional configuration are:

  • Throughput (the lower the better).
  • App server response time (the lower the better).
  • Most called URLs.
  • Time each process takes to process your requests divided in layers: app server, database, response time, etc.
  • Hosts where your app is running (pods).

You Might Also Like

No Comments

Leave a Reply