Monitor Java applications with jolokia and hawtio


Use jolokia and hawtio to get MBean information etc. of Java application.

What is jolokia

A Java agent for accessing MBeans via http. Since it can be accessed via http, MBean information can be easily collected with curl or the like. The collected information will be returned in JSON.

What is hawtio

hawtio is a web console that allows you to monitor and manage Java applications. As standard, it supports Tomcat, Apache Camel, Apache ActiveMQ, etc. Other Java applications can also display MBean and JVM information acquired by JMX.

In JMX, hawtio does not communicate with the application by JMX, but http communication with the backend jolokia to collect MBean information and display it on the screen. In other words, hawtio and jolokia can be combined to access various remote Java applications via JMX.

This time, as a Java application to be monitored, I will try to run it using kafka that happened to be running on the server.


In addition, the procedure referred to the following article.

play + jolokia + hawtio


Download jolokia

Download jolokia's Agent from the following site.


Run jolokia

jolokia can be run standalone or embedded in a Java application.

(1) Run jolokia standalone

Execute the following command to display the process list of the Java application.

# java -jar jolokia-jvm-1.6.0-agent.jar 
3906   kafka.Kafka ../config/
4229   jolokia-jvm-1.6.0-agent.jar
1039   org.apache.zookeeper.server.quorum.QuorumPeerMain /opt/kafka/config/

The command options are as follows.

Usage: java -jar jolokia-jvm-1.6.0-agent.jar [options] <command> <pid/regexp>
where <command> is one of
    start     -- Start a Jolokia agent for the process specified
    stop      -- Stop a Jolokia agent for the process specified
    status    -- Show status of an (potentially) attached agent
    toggle    -- Toggle between start/stop (default when no command is given)
    list      -- List all attachable Java processes (default when no argument is given at all)
    encrypt   -- Encrypt a password which is given as argument or read from standard input

Next, run jolokia as follows. The last "3906" is the process ID of the Java application to be monitored. "Http://" displayed on the screen after execution will be the access destination to jolokia. The user ID and password for authentication of jolokia are "jolokia".

# java -jar jolokia-jvm-1.6.0-agent.jar --user jolokia --password jolokia start 3906
Started Jolokia for PID 3906

(2) Execute jolokia by embedding it in a Java application

Add the following to your Java startup options: Change the path of "jolokia-jvm-1.6.0-agent.jar" according to your environment.


Jolokia version check

Access jolokia via http and try to get the version information.

# curl http://localhost:8778/jolokia/version
{"request":{"type":"version"},"value":{"agent":"1.6.0","protocol":"7.2","config":{"listenForHttpService":"true","maxCollectionSize":"0","authIgnoreCerts":"false","agentId":"","debug":"false","agentType":"jvm","policyLocation":"classpath:\/jolokia-access.xml","agentContext":"\/jolokia","serializeException":"false","mimeType":"text\/plain","maxDepth":"15","authMode":"basic","discoveryEnabled":"true","streaming":"true","canonicalNaming":"true","historyMaxEntries":"10","allowErrorDetails":"true","allowDnsReverseLookup":"true","realm":"jolokia","includeStackTrace":"true","maxObjects":"0","useRestrictorService":"false","debugMaxEntries":"100"},"info":{"product":"jetty","vendor":"Eclipse","version":"9.2.24.v20180105"}},"timestamp":1542198764,"status":200}[root@kafkaserver1 ~]# 

Try to get metrics

Next, try accessing jolokia via http to get the metrics.

# curl http://localhost:8778/jolokia/read/java.lang:type=Memory/NonHeapMemoryUsage
{"request":{"mbean":"java.lang:type=Memory","attribute":"NonHeapMemoryUsage","type":"read"},"value":{"init":2555904,"committed":53477376,"max":-1,"used":50092648},"timestamp":1542198810,"status":200}[root@kafkaserver1 ~]# 

Stop jolokia (if it was running standalone)

To stop Jolokia, execute the following command.

# java -jar jolokia-jvm-1.6.0-agent.jar stop 3906
Stopped Jolokia for PID 3906

Run hawtio

Download hawtio

Download the hawtio module from the following site. This time, I downloaded "hawtio-app-2.3.0.jar".


Run hawtio

Run hawtio with the following command. "--Port 8090" specifies the port used by hawtio.

java -jar hawtio-app-2.3.0.jar --port 8090

hawtio: Don't cha wish your console was hawt like me!

Access the hawtio web console

The URL of the hawtio web console is as follows.


When you open it with a browser, the following screen will be displayed.


I will try to connect to jolokia immediately.

First, click the "Add connection" button. A dialog for entering jolokia connection information will be displayed. Enter it as shown on the screen.


When you click "Test Connection", the dialog for entering the user ID and password of jolokia is displayed. Enter the "jolokia" that was set when jolokia was started.


If "Connected successfully" is displayed, it is successful. Finally, click the "Add" button.


Take a look at Kafka

Click the "Connect" button to open another window.

Select the JMX tab to see information about kafka's MBeans.


You can see information about the JVM's System Properties, threads, Class Histogram, etc. in the Runtime.






-Visualize Camel web application deployed on Tomcat9 with hawtio

Recommended Posts

Monitor Java applications with jolokia and hawtio
Build and test Java + Gradle applications with Wercker
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
Install Java and Tomcat with Ansible
Easily Docker Java applications with Jib
Use JDBC with Java and Scala.
Output PDF and TIFF with Java 8
Encrypt with Java and decrypt with C #
Link Java and C ++ code with SWIG
Let's try WebSocket with Java and javascript!
[Java] Reading and writing files with OpenCSV
CICS-Run Java applications-(3) Build management with Gradle
CICS-Run Java applications-(2) Build management with Maven
Create Java applications with IBM Cloud Functions
Beginners create web applications with Java and MySQL (adding at any time)
Try to link Ruby and Java with Dapr
JSON with Java and Jackson Part 2 XSS measures
Java and JavaScript
XXE and Java
Prepare a scraping environment with Docker and Java
KMS) Envelope encryption with openssl and java decryption
Encrypt / decrypt with AES256 in PHP and Java
[Java] Convert and import file values with OpenCSV
[Review] Reading and writing files with java (JDK6)
[Java] Align characters even with mixed half-width and full-width characters
Use fast Mapping library MapStruct with Lombok and Java 11
CI the architecture of Java / Kotlin applications with ArchUnit
Solving with Ruby and Java AtCoder ABC129 D 2D array
Summary of ToString behavior with Java and Groovy annotations
Compile with Java 6 and test with Java 11 while running Maven on Java 8
Solving with Ruby, Perl and Java AtCoder ABC 128 C
Monitor the internal state of Java programs with Kubernetes
[Java] Refer to and set private variables with reflection
I want to transition screens with kotlin and java!
Prepare the environment for java11 and javaFx with Ubuntu 18.4
Face recognition app made with Amazon Rekognition and Java
[Java] Development with multiple files using package and import
Serverless Java EE starting with Quarkus and Cloud Run
Install java with Homebrew
Getters and setters (Java)
Change seats with java
[Java] Thread and Runnable
Install Java with Ansible
Java true and false
[Java] String comparison and && and ||
Comfortable download with JAVA
Switch java with direnv
Java --Serialization and Deserialization
[Java] Arguments and parameters
Download Java with Ansible
timedatectl and Java TimeZone
[Java] Branch and repeat
Let's scrape with Java! !!
Build Java with Wercker
[Java] Variables and types
java (classes and instances)
[Java] Overload and override
Endian conversion with JAVA
Monitor source code changes with guard-shell and make & execute automatically
Store in Java 2D map and turn with for statement