1

I am using Spring Actuator via its JMX interface to provide metrics to our monitoring team.

Our monitoring team is using tools that can track specific MBean attributes. With "standard" JMX, like the one that is being exposed by Tomcat, this works fine. However, in Spring Actuator, the exposed MBeans are simply SENSITIVE, ENDPOINT, and DATA. DATA contains a json with ALL the attributes inside it (similar to what you'll see in the http interface).

Is there any way to expose specific information (for example, mem usage, threads.active etc.) as their own MBean attributes, instead of displaying all the attributes as a big JSON?

Spring's JMX solution is not user-friendly for many production monitoring tools as at its default.

I tried to check jolokia but I wan't able to understand from the documentation if this framework will give what I need.

Thanks!

odedia
  • 931
  • 2
  • 11
  • 27

1 Answers1

0

Pls use following code to see METRIX node in MBEAN tab on jconsole showing complete details on JVM memory, thread & GC states.

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
import com.codahale.metrics.jvm.ThreadStatesGaugeSet;

@Configuration
public class Metrix {

    @Bean
    public JmxReporter jmxReporter() {
        JmxReporter reporter = JmxReporter.forRegistry(getMetricRegistry()).build();
        reporter.start();
        return reporter;
    }

    public MetricRegistry getMetricRegistry() {
        MetricRegistry metricRegistry = new MetricRegistry();
        metricRegistry.register("jvm-thread-state", new ThreadStatesGaugeSet());
        metricRegistry.register("jvm-mem", new MemoryUsageGaugeSet());
        metricRegistry.register("jvm-gc", new GarbageCollectorMetricSet());
        return metricRegistry;
    }
}

Use following libraries:-
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
</dependency>
<dependency>
    <groupId>io.dropwizard.metrics</groupId>
    <artifactId>metrics-core</artifactId>
    <version>3.1.2</version>
</dependency>
<dependency>
    <groupId>io.dropwizard.metrics</groupId>
    <artifactId>metrics-jvm</artifactId>
    <version>3.1.2</version>
</dependency>
Avis
  • 2,197
  • 18
  • 28
  • Thanks I'll try this. Is there any documentation for all the various attribute classes I can expose, other than those 3? – odedia Jun 04 '16 at 06:34
  • Not much documentation can be found but i have explored it once while implementing it. They are BufferPoolMetricSet, CachedThreadStatesGaugeSet, ClassLoadingGaugeSet, GarbageCollectorMetricSet, MemoryUsageGaugeSet, ThreadStatesGaugeSet. – Avis Jun 06 '16 at 22:42