When implementing a monitoring solution for your Java environment, choosing the correct integration option is an essential part of that decision. The integration option you choose will determine several important characteristics, including:
- What metrics you are concerned about collecting and analyzing
- How metrics will be gathered from your application
- How metrics will be transferred to your Java monitoring provider
- What additional configuration will be required for your application to fully integrate with the infrastructure monitoring provider
Which Java Monitoring Integration is Best?
Netuitive provides five different integrations for monitoring your Java applications. Of course, the one that is the “best” choice for you will depend on your needs and your environment.
To help you determine the best fit for your needs, this article explores each of the integrations available for use with Netuitive. For each, we’ll explore what level of effort is involved in setting up the integration, any dependencies the integration relies on, and how to configure the integration and get metrics flowing into your Netuitive account.
Before we begin, there are some fundamental questions which might narrow down which of the five Java monitoring options you should look at first.
Are you looking to examine JVM metrics or Application metrics?
- JVM Metrics
- Consider either the Java Agent or JMX integration.
- Application Metrics
- Are you using Dropwizard?
- With Dropwizard metrics, you have the choice of submitting results through StatsD, or through the Netuitive Rest API.
- Do you have, or do you wish to have, either a StatsD server or the StatsD daemon running?
- Consider the Ananke library.
- Would you prefer to submit your metrics through the Netuitive Rest API?
- Consider the Iris Library.
- Are you using Dropwizard?
JVM Metrics Vs. Application Metrics
The Java Virtual Machine (JVM) is the container that allows a Java application to be executed independently of the underlying operating system. When running a Java application, it is important to monitor the health of the underlying JVM. Some important metrics to monitor include:
- Process availability – Whether the JVM is running
- Java Heap Usage – The memory in use by the JVM
- Garbage Collection – How long and how often the Garbage Collector runs
- Active Threads – How work is processed through the application
- Response Time – How responsive the application is to requests
Users of your application have an expectation that requests should be returned quickly and with accurate results. Application metrics allow you to monitor this and ensure that users are experiencing the application in a positive manner. Some metrics you’ll want to monitor are:
- Duration between request and response
- Error counts and percentage of total request counts that return errors.
- Request rate
Choosing Between StatsD and the Netuitive Rest API
StatsD was originally developed by the engineers at Etsy, and is a simple NodeJS daemon that listens for messages, extracts metrics, and can then be used to push the data to a datastore, or a monitoring service like Netuitive.
The original StatsD offering has been used as a reference implementation for some other projects, including Netuitive StatsD. If you already have a StatsD server, you can configure it to push metrics to Netuitive. If you don’t yet have a StatsD server, one is installed as part of the Netuitive Linux Agent.
The Netuitive RESTful API allows developers to interact with Netuitive, both to push metrics into the Netuitive system and to retrieve information programmatically. Metrics are received in the form of events, which are in turn digested by the Netuitive system, and are made available for use in Java monitoring dashboards and Netuitive’s other analytical offerings.
Let’s look at each of the integrations in more detail.
The name Ananke comes from Greek mythology and refers to a being that embodies necessity, and the idea of a force which exists from the beginning and encompasses all. It’s an appropriate name for a metrics library that can monitor all aspects of your application.
The Ananke library gathers and submits metrics to the StatsD daemon, which is a dependency of using this library, and is included in the Netuitive Linux Agent. Ananke can report a variety of metrics, including:
- Timing measurements
To use Ananke to monitor your application, you’ll need to include Ananke as a dependency for your project, and instantiate a StatsDClient which can be accessed from all relevant classes.
To submit an event, such as the time for a page to load, you would pass a callable function into the client.
Dropwizard is a collection of libraries that have been curated into a framework which allows developers to focus on creating applications, without having to spend time investigating and building a platform to support the application. One of the libraries available to users of this framework is the Dropwizard Metrics library. This library enables unparalleled insight and visibility into all levels of your application.
Dropwizard metrics are typically accessed through the admin endpoint for the application; however, by including Netuitive dropwizard-metrics as a runtime dependency for your project; you can configure the submission of the entire metrics suite to the StatsD daemon, or to the Netuitive Restful API.
Iris is a Java SDK from Netuitive that allows you to interact programmatically with the Netuitive API. After including the library as a dependency of your project, you will need to create an instance of the appropriate Netuitive client, which is accessible by relevant classes with your application.
After creating a list of IngestEvent objects called events, you could then submit them to the ingestClient instance as follows:
An advantage of Iris is that it allows for both creation/submission of metrics to the API, as well as the retrieval of metrics and other Netuitive resources from the API. The API is well documented and can be further explored if you have a Netuitive account.
Java Monitoring Agent
The Netuitive Java monitoring agent is based on the Zorka Monitoring Agent, an open source monitoring agent for the JVM. The agent provides byte-code instrumentation without needing the change source code, and allows for the collection of standard JVM runtime metrics, including:
- Garbage Collector (GC)
Additional application metrics are collected and reported as well.
You will need to have an active Netuitive account to make use of the agent. To install the agent, you will need to download and unzip the Netuitive Agent. You will then need to locate the zorka.properties file and update it with your API Key provided by Netuitive.
Pro Tip: You can get your Java API key by logging into your Netuitive account, navigating to Integrations, and then clicking on the Java button. Your API key will be displayed right below the header.
Finally, you’ll need to restart your JVM, passing in the -javaagent flag with the path to the netuitive-zorka directory as a property. Your command should look similar to the following.
The Netuitive JMX solution uses Jolokia to publish metrics to the Netuitive Linux agent. The name Jolokia comes from the ghost pepper that is grown largely in eastern Asia, and was chosen to represent the Jolokia project because it was going to be the “hot” new way of gathering metrics using JMX.
To set up the JMX integration, you’ll need to first install the Linux agent. Log into your Netuitive account, navigate to Integrations, and then click on the Linux button. You’ll be shown a shell command with your personal API key included to be used for installing the Linux agent on your machine.
Once the Linux agent is installed, you’ll want to download the Jolokia jar and install it in the /opt/netuitive-agent/ directory. Next, navigate to the collectors folder (Usually located at /opt/netuitive-agent/conf/collectors) and open the JolokiaCollector.conf file and change the enabled setting to true.
Restart the Linux agent, using the appropriate command for your Linux distribution.
Finally, add the javaagent flag to the command which starts your application. It should look similar to the command below.
Which Java Monitoring Works For You?
Each of the integrations we looked at here provides a way to push metrics from your application up to Netuitive for analysis—and Iris even lets you pull them back down again. What frameworks you’re already using, what tools you may already have installed, and which Java monitoring metrics you are looking to gather are key to identifying which will work best for you.
Mike Mackrory is a Global citizen who has settled down in the Pacific Northwest – for now. By day he works as a Senior Engineer on a Quality Engineering team and by night he writes, consults on several web based projects and runs a marginally successful eBay sticker business. When he’s not tapping on the keys, he can be found hiking, fishing and exploring both the urban and the rural landscape with his kids. Always happy to help out another developer, he has a definite preference for helping those who bring gifts of gourmet donuts, craft beer and/or Single-malt Scotch.
Leave traditional Java monitoring behind – sign up for Netuitive’s fully-featured, 21-day free trial.