Skip to main content

Java Monitoring

Professional

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​

info

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

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

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

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

MetricDescription
myapplication_jvm_gcNumber of garbage collection per second
myapplication_jvm_gc_utilizationGarbage collection utilization in percent
myapplication_jvm_heap_usedHeap memory used in bytes
myapplication_jvm_non_heap_usedNon-Heap memory used in bytes

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

service:
- type: 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 know the mbean name and attribute name to the metric. Then add the following to your Bleemeo agent configuration (/etc/glouton/conf.d/50-java.conf):

service:
- type: 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,name=*"
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
# Sum metrics over type_names.
sum: True
type_names: []string{"name"}
# Divide the result by the "accounts" attribute.
ratio: accounts

The above configuration will create two metrics:

MetricDescription
myapplication_heap_size_mbThe size of the heap memory in megabytes
myapplication_requestThe average of request per second per account that a custom application does