Spring Boot Actuator JMX Metrics Exporter

Library to export JMX MBean attributes as Spring Boot Actuator metrics

License

License

Categories

Categories

Spring Boot Container Microservices Net Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

net.bjohannsen
ArtifactId

ArtifactId

spring-boot-actuator-jmx-metrics-exporter
Last Version

Last Version

2.0.1-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

Spring Boot Actuator JMX Metrics Exporter
Library to export JMX MBean attributes as Spring Boot Actuator metrics
Project URL

Project URL

https://github.com/bjohannsen/spring-boot-actuator-jmx-metrics-exporter
Source Code Management

Source Code Management

https://github.com/bjohannsen/spring-boot-actuator-jmx-metrics-exporter

Download spring-boot-actuator-jmx-metrics-exporter

How to add to project

<!-- https://jarcasting.com/artifacts/net.bjohannsen/spring-boot-actuator-jmx-metrics-exporter/ -->
<dependency>
    <groupId>net.bjohannsen</groupId>
    <artifactId>spring-boot-actuator-jmx-metrics-exporter</artifactId>
    <version>2.0.1-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/net.bjohannsen/spring-boot-actuator-jmx-metrics-exporter/
implementation 'net.bjohannsen:spring-boot-actuator-jmx-metrics-exporter:2.0.1-RELEASE'
// https://jarcasting.com/artifacts/net.bjohannsen/spring-boot-actuator-jmx-metrics-exporter/
implementation ("net.bjohannsen:spring-boot-actuator-jmx-metrics-exporter:2.0.1-RELEASE")
'net.bjohannsen:spring-boot-actuator-jmx-metrics-exporter:jar:2.0.1-RELEASE'
<dependency org="net.bjohannsen" name="spring-boot-actuator-jmx-metrics-exporter" rev="2.0.1-RELEASE">
  <artifact name="spring-boot-actuator-jmx-metrics-exporter" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.bjohannsen', module='spring-boot-actuator-jmx-metrics-exporter', version='2.0.1-RELEASE')
)
libraryDependencies += "net.bjohannsen" % "spring-boot-actuator-jmx-metrics-exporter" % "2.0.1-RELEASE"
[net.bjohannsen/spring-boot-actuator-jmx-metrics-exporter "2.0.1-RELEASE"]

Dependencies

runtime (8)

Group / Artifact Type Version
io.micrometer : micrometer-core jar 1.0.10
org.slf4j : slf4j-api jar 1.7.26
org.springframework : spring-context jar 5.0.13.RELEASE
org.springframework.boot : spring-boot-actuator jar 2.0.9.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 2.0.9.RELEASE
com.fasterxml.jackson.core : jackson-core jar 2.9.8
com.fasterxml.jackson.core : jackson-annotations jar 2.9.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.8

Project Modules

There are no modules declared in this project.

Build Build Maven Central

spring-boot-actuator-jmx-metrics-exporter

Glue Library to publish JMX MBean attributes as Spring Actuator metrics. Supports simple attribute values that can be parsed as a Number as well as composite attribute types.

It reads configured attributes from MBeans and submits them to the Spring Boot Actuator metrics system (i.e. Micrometer). The JMX data is scraped in a configurable interval to avoid performance issues.

How to use

Add dependency:

runtime 'net.bjohannsen:spring-boot-actuator-jmx-metrics-exporter:2.0.1-RELEASE")

Requirements:

  • Java 11 or higher
  • Micrometer (Spring Boot2 Actuator or Spring Boot 1.5 with Micrometer Legacy adapter)
  • Jmx should be enabled in spring config ((spring.jmx.enabled=true). It is disabled by default since Spring Boot 2.2)

Configuration

Configuration property prefix is 'jmx-metrics-export'.

Properties

Key Default Description
enabled false Enable metrics
prefix jmx Prefix for exposed metrics
scrape-interval 10000 Interval to scrape data from MBeans in milliseconds
config-files classpath:jmx-metrics-exporter.json List of resource links to mbean config json files (see below)

jmx-metrics-exporter.json

{
  "prefix": "jmx",
  "mbeans": [
    {
      "mbeanName": "net.bjohannsen.spring.boot.actuator.metrics.jmxexporter:name=mBean,type=MBeanClass",
      "metricName": "myMetric",
      "attributes": ["SomeAttribute", "AnotherAttribute"]
    }
  ]
}

The example will expose metrics 'jmx.myMetric.SomeAttribute' and 'jmx.myMetric.AnotherAttribute'. Multiple config files can be specified and will be used in an additive manner.

Composite types

To export composite type members, simply config the attribute as 'attributeName.memberKey' format. Example:

...
  "mbeans": [
    {
      "mbeanName": "java.lang:type=Memory",
      "metricName": "memory",
      "attributes": ["HeapMemoryUsage.max"]
    }
  ]
...

Examples

Example configurations for application.yml and config files can be found in the application-test.yml and mbean-metrics-config.json.

Versions

Version
2.0.1-RELEASE
2.0.0-RELEASE
1.1.1-RELEASE
1.1.0-RELEASE
1.0.0-RELEASE