diziaq
diziaq

Reputation: 7815

How to enable all SpringBoot actuator endpoints?

SpringBoot v2.5.1

I would like to have all actuator endpoints (described in documentation) available. Following the docs, have added actuator starter dependency and a property, but most of the endpoints are not available (HTTP 404).

The only available endpoint is GET /actuator/health, but it shows useless info: {"status": "UP"}

Added property management.endpoints.enabled-by-default=true.

Added dependency:

 <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
 </dependency>

Result of GET /actuator

{
    "_links": {
        "self": {
            "href": "http://localhost:9999/actuator",
            "templated": false
        },
        "health-path": {
            "href": "http://localhost:9999/actuator/health/{*path}",
            "templated": true
        },
        "health": {
            "href": "http://localhost:9999/actuator/health",
            "templated": false
        }
    }
}

What is the minimal set up to enable actuator endpoints?

Upvotes: 1

Views: 2116

Answers (2)

Penny Liu
Penny Liu

Reputation: 17488

I am using IntelliJ IDEA 2024.1.4 (Ultimate Edition) for macOS.

I followed these steps,

Simply add the dependency to your pom.xml file.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Next, update the application.properties file.

To expose all endpoints, use the wildcard *. Alternatively, you can expose individual endpoints with a comma-delimited list (e.g., health,info,...)

management.endpoints.web.exposure.include=*

Please note that the console will display additional endpoints, with actuator endpoints being prefixed by /actuator.

endpoints

To view actuator endpoints, go to /mappings. This is for demonstration, so you can try any endpoint from the full list.

mappings

You can install the JSON Formatter extension to make JSON easier to read.

Upvotes: 1

pcsutar
pcsutar

Reputation: 1829

Add micrometer-core and micrometer-registry-prometheus dependencies in your pom.xml file:

<!-- Spring boot actuator to expose metrics endpoint -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Micormeter core dependecy -->
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
</dependency>

<!-- Micrometer Prometheus registry -->
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

Add below properties in your application.properties file:

#Metrics related configurations
management.endpoint.metrics.enabled          = true
management.endpoints.web.exposure.include    = *
management.endpoint.prometheus.enabled       = true
management.metrics.export.prometheus.enabled = true

If you need to expose everything over HTTP then you need to set management.endpoints.web.exposure.include as shown in above example. In your code this property is missing. Please refer spring docs if you wish to expose specific endpoints. I have also added dependencies in above examples which are required to expose prometheus related endpoints.

Upvotes: 1

Related Questions