Java Monitoring

Bleemeo agent supports monitoring Java application with Java Management Extensions (JMX). By default for any monitored JVM, it will gather metrics about memory usage (heap and non-heap) and garbage collection time.

Installation

A Java environment is required to retrieve JMX metrics. It is not installed by default in Bleemeo. To support JMX metrics, install the additional package bleemeo-agent-jmx.

For Ubuntu/Debian:

sudo apt-get install bleemeo-agent-jmx

For CentOS/Fedora:

sudo yum install bleemeo-agent-jmx

Monitor a Java application

Note

For supported services, Bleemeo agent try to auto-detect the JMX port, if it succeed no manual configuration is needed.

To monitor a Java application, create a configuration file with the following content (/etc/bleemeo/agent.conf.d/50-java.conf):

service:
    - id: myapplication
      address: 127.0.0.1
      jmx_port: 1234

With this configuration, Bleemeo agent will use JMX on TCP port 1234 to gather metrics:

  • myapplication_jvm_gc: Number of garbage collection per second.
  • myapplication_jvm_gc_time: Time spent doing garbage collection in milliseconds per second.
  • myapplication_jvm_gc_utilization: Garbage collection utilization in percent.
  • myapplication_jvm_heap_used: Heap memory used in bytes.
  • myapplication_jvm_non_heap_used: Non-Heap memory used in bytes.

It is also possible to provide a username and password if authentication is required to access JMX:

service:
    - id: myapplication
      jmx_port: 1234
      jmx_username: monitorRole
      jmx_password: secret

Custom JMX metrics

In addition to the default metrics monitored, any metrics exported by JMX can be gathered. You only need to known the mbean name and attribute name to the metric. Then add the following to your Bleemeo agent configuration (/etc/bleemeo/agent.conf.d/50-java.conf):

service:
    - id: myapplication
      jmx_port: 1234
      jmx_metrics:
        - name: heap_size_mb
          mbean: java.lang:type=Memory
          attribute: HeapMemoryUsage
          # HeapMemoryUsage attribute is a composite attribute with
          # committed, init, max and used sub-attribute.
          # path is used to select the wanted one.
          path: used
          scale: 0.000000954  # 1 / 1024 / 1024
        - name: request
          mbean: com.bleemeo.myapplication:type=ClientRequest
          attribute: Count
          # The bean expose total request since JVM start. With derive=True,
          # Bleemeo-agent will return the number of request per second.
          derive: True

The above configuration will create two metrics:

  • myapplication_heap_size_mb: The size of the heap memory in megabytes.
  • myapplication_request: The number of request per second that a custom application does.