A JBoss Project
Red Hat

Health

It's very handy to add health checks to Java code running in a JVM and exposing those health checks over JMX. e.g. see the dropwizard notes and the metrics library health checks.

This document outlines a Health check MBean convention that if folks adopt its then easier to discover and will be included in the Console's Health tab.

Health MBean Convention

Create at least one MBean and register it with a JMX ObjectName including service=Health.

For example an ObjectName could be

org.apache.activemq:type=Broker,brokerName=localhost,service=Health

The MBean should then have these methods

  • health() which returns a JMX compliant data structure such as tabular or composite data
  • heathList() which returns a List<Object> or array of objects for use by tools like Jolokia that marshal objects nicely to JSON to avoid JMX's marshalling pain.

Each health status object should include the following properties if possible…

Property Description
healthId The unique ID of the kind of health check performed. We can then use this unique kind ID to generate useful UI tooling & descriptions. Ideally the code should be fully qualified in the same way as Java classes, such as org.apache.activemq.noConsumer
level The severity level such as INFO, WARN, ERROR, CRITICAL to give some indication of how serious the problem is. INFO means its OK and healthy.
message A textual description of the health check status.
resource The JMX ObjectName of the thing causing the issue. If its hard to do, just include plenty of other properties to describe the resource/component that caused the issue
Examples

To show you how to implement a Health MBean here are a few examples.