Interactive Java JVM Monitoring on Kubernetes - Configuring VisualVM to use JMXMP
Jean-François Lamy
Posted on May 21, 2020
This is part 2 of a 2-part series.
Despite feature requests to do so and some work to create a plugin, VisualVM does not ship with JMXMP configured by default. The following recipe has been tested with VisualVM 2.0.1.
If we used Maven to enable our application, we have a copy of the required java archive (jar) in the .m2 directory. The simple way is to add that jar to the class path using the --cp:a
option. This jar would normally have to be "endorsed" to be used, but starting from the directory where it is found allows things to work.
cd C:\Dev\.m2\repository\org\glassfish\external\opendmk_jmxremote_optional_jar\1.0-b01-ea
C:\Dev\Java\visualvm_201\bin\visualvm.exe --cp:a opendmk_jmxremote_optional_jar-1.0-b01-ea.jar
You can also create a shortcut on your desktop to run the command. Use the Start In
option to select the directory where the jmxremote jar is found.
Adding a remote host
When accessing a remote host such as KubeSail, add it using the add remote host
option
Configure a connection
Under the new host (or under Local if connecting locally), right-click and use Add JMX Connection
. Use the accessible address.
- If running locally, this will be localhost, and the syntax will be
service:jmx:jmxmp://localhost:1098
- if remote, the external address obtained by querying the pod.
In our example, that yields
service:jmx:jmxmp://54.151.2.??:300??
(the port is the one listed in the NodePort configuration as explained in Part 1.)
- Double-clicking on the new connection will open it, and the name of the monitored application will be shown. You can then use the various tabs to monitor, examine or sample the application.
Posted on May 21, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.