MetricsServlet doesn't update or list other metrics

65 views
Skip to first unread message

Tan-Vinh Nguyen

unread,
Jun 11, 2015, 11:42:01 AM6/11/15
to metric...@googlegroups.com
  • I just trying out the reporting with HTTP.
  • MetricsServlet gives following JSON output.
  • I have only one MetricsRegistry in the application/JVM.

{
 
"version" : "3.0.0",
 
"gauges" : {
   
"jmsQueue" : {
     
"value" : 2
   
}},
 
"counters" : { },
 
"histograms" : { },
 
"meters" : { },
 
"timers" : { }
}

  • If I refresh the web-page the JSON will be updated only for listed gauge.
  • Other metrics are not added or listed.
  • Another reporter (Slf4jReporter) reports correctly all other metrics

17:28:15,392 INFO  [metrics-reporter-demo] (metrics-logger-reporter-28-thread-1) type=COUNTER, name=Transaction.approved.count, count=1
17:28:15,392 INFO  [metrics-reporter-demo] (metrics-logger-reporter-28-thread-1) type=HISTOGRAM, name=approved, count=1, min=1, max=1, mean=1.0, stddev=0.0, median=1.0, p75=1.0, p95=1.0, p98=1.0, p99=1.0, p999=1.0
17:28:58,840 INFO  [metrics-reporter-demo] (metrics-logger-reporter-1-thread-1) type=GAUGE, name=jmsQueue, value=2


I'm not sure if my assumption is right, but if I hit the webpage or invoke the MetricsServlet again, the metrics / JSON output should be updated?


I used the a simple Java EE 6 - EAR running under JBoss EAP 6.4.0


My servlet uses a singleton bean

@WebListener
public class DemoMetricsServletContextListener extends MetricsServlet.ContextListener {

   
@Inject
   
private DemoMetrics metrics;

   
@Override
   
protected MetricRegistry getMetricRegistry() {
       
return metrics.getRegistry();
   
}
}


All other metrics uses this singleton bean to register against the MetricsRegistry

@Startup
@Singleton(description = "contains the single metrics registry")
public class DemoMetrics {

   
private final MetricRegistry registry;

   
public DemoMetrics() {
        registry
= new MetricRegistry();

       
try {
            setupJmxGauges
();
            setupJvmGauges
();
       
} catch (MalformedObjectNameException e) {
            LOGGER
.error("error in setup JMX metrics", e);
       
}

       
final Slf4jReporter reporter = Slf4jReporter.forRegistry(registry).outputTo(LoggerFactory.getLogger("metrics-reporter-demo")).convertRatesTo(TimeUnit.SECONDS).build();
        reporter
.start(1, TimeUnit.MINUTES);
   
}
   
//..
}


Any pointers or confirmation might be helpful.

Lakshmipriya Sreelal

unread,
Dec 3, 2015, 10:18:16 AM12/3/15
to metrics-user
Hi,

Have you got it worked. I am stuck at the very same stage.

Cheers,
Lakshmi

Tan-Vinh Nguyen

unread,
Dec 8, 2015, 4:36:24 AM12/8/15
to metric...@googlegroups.com
Hi,

I move forward using the JMX Reporter and exposed the metrics with jolokia.war. Much more reliable and unified way.

HTH

--
You received this message because you are subscribed to a topic in the Google Groups "metrics-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/metrics-user/k0mNFHk1saM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to metrics-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages