Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Actuator to Give CPU Usage

I would like to know is there a way to get the CPU Usage metrics with Spring Boot Actuator? Im able to see other metrics with /metrics and /health endpoints but not getting the CPU Usage. I want to avoid writing an extra class just to see the CPU Usage. Any idea? Thanks

like image 487
user2340345 Avatar asked Jun 23 '16 08:06

user2340345


People also ask

What value does spring boot actuator provide?

What value does Spring Boot Actuator provide? Spring Boot actuator allows you to monitor and interact with your application which is very important for a production application. Without a spring boot actuator, you need to build your own monitoring and interaction system using JMX.

How do you run an actuator on a spring boot?

To enable Spring Boot actuator endpoints to your Spring Boot application, we need to add the Spring Boot Starter actuator dependency in our build configuration file. Maven users can add the below dependency in your pom. xml file. Gradle users can add the below dependency in your build.

Why actuators are used in spring boot?

Actuator is mainly used to expose operational information about the running application — health, metrics, info, dump, env, etc. It uses HTTP endpoints or JMX beans to enable us to interact with it.


1 Answers

Just checked and I found this actuator... /actuator/metrics/process.cpu.usage

It outputs the following:

{
    name: "process.cpu.usage",
    description: "The "recent cpu usage" for the Java Virtual Machine process",
    baseUnit: null,
    measurements: [
        {
            statistic: "VALUE",
            value: 0.0001742149747252696
        }
    ],
    availableTags: [ ]
}

Currently using Spring Boot version 2.2.2.RELEASE.

like image 165
Jose Martinez Avatar answered Sep 30 '22 00:09

Jose Martinez