Reputation: 1618
Is there a way to measure CPU usage and Utilization of different aspects (CPU, Thread, Memory etc) using dropwizard
in spring-boot
?
Upvotes: 1
Views: 4996
Reputation: 4160
Use spring-boot-actuator
for that. There is already a /metrics
endpoint for the data you are asking for.
Check systemload.average
, mem
, mem.free
, threads
etc for the exact information.
For more information check:
https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-dropwizard-metrics
A default
MetricRegistry
Spring bean will be created when you declare a dependency to theio.dropwizard.metrics:metrics-core
library; you can also register you own@Bean
instance if you need customizations. Users of the Dropwizard ‘Metrics’ library will find that Spring Boot metrics are automatically published tocom.codahale.metrics.MetricRegistry
. Metrics from theMetricRegistry
are also automatically exposed via the/metrics
endpointWhen Dropwizard metrics are in use, the default
CounterService
andGaugeService
are replaced with aDropwizardMetricServices
, which is a wrapper around theMetricRegistry
(so you can@Autowired
one of those services and use it as normal). You can also create “special” Dropwizard metrics by prefixing your metric names with the appropriate type (i.e. timer., histogram. for gauges, and meter.* for counters).
Upvotes: 2