Using JMX with Solr

Java Management Extensions (JMX) is a technology that makes it possible for complex systems to be controlled by tools without the systems and tools having any previous knowledge of each other. In essence, it is a standard interface by which complex systems can be viewed and manipulated.

Solr, like any other good citizen of the Java universe, can be controlled via a JMX interface. Once enabled, you can use a JMX client, like jconsole, to connect with Solr.

If you are unfamiliar with JMX, you may find the following overview useful: http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html.

Configuring JMX

JMX support is configured by defining a metrics reporter, as described in the section the section JMX Reporter.

If you have an existing MBean server running in Solr’s JVM, or if you start Solr with the system property -Dcom.sun.management.jmxremote, Solr will automatically identify it’s location on startup even if you have not defined a reporter explicitly in solr.xml. You can also define the location of the MBean server with parameters defined in the reporter definition.

Configuring MBean Servers

Versions of Solr prior to 7.0 defined JMX support in solrconfig.xml. This has been changed to the metrics reporter configuration defined above. Parameters for the reporter configuration allow defining the location or address of an existing MBean server.

An MBean server can be started at the time of Solr’s startup by passing the system parameter -Dcom.sun.management.jmxremote. See Oracle’s documentation for additional settings available to start and control an MBean server at http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html.

Configuring a Remote Connection to Solr JMX

If you need to attach a JMX-enabled Java profiling tool, such as JConsole or VisualVM, to a remote Solr server, then you need to enable remote JMX access when starting the Solr server. Simply change the ENABLE_REMOTE_JMX_OPTS property in the solr.in.sh or solr.in.cmd (for Windows) file to true. You’ll also need to choose a port for the JMX RMI connector to bind to, such as 18983. For example, if your Solr include script sets:

ENABLE_REMOTE_JMX_OPTS=true
RMI_PORT=18983

The JMX RMI connector will allow Java profiling tools to attach to port 18983. When enabled, the following properties are passed to the JVM when starting Solr:

-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.port=18983 \
-Dcom.sun.management.jmxremote.rmi.port=18983

We don’t recommend enabling remote JMX access in production, but it can sometimes be useful when doing performance and user-acceptance testing prior to going into production.

For more information about these settings, see: http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html.

Making JMX connections into machines running behind NATs (e.g., Amazon’s EC2 service) is not a simple task. The java.rmi.server.hostname system property may help, but running jconsole on the server itself and using a remote desktop is often the simplest solution. See http://web.archive.org/web/20130525022506/http://jmsbrdy.com/monitoring-java-applications-running-on-ec2-i.

Comments on this Page

We welcome feedback on Solr documentation. However, we cannot provide application support via comments. If you need help, please send a message to the Solr User mailing list.