Kaushik Lele
Kaushik Lele

Reputation: 6637

Spring boot actuator "/health" is not working

I have a running Springboot application which serves the URL http://localhost:8081/topics and returns me JSON response as expected.

I added actuator dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <scope>test</scope> </dependency>

as suggested in tutorial

But when I hit http://localhost:8081/health it does not give expected result. It says

{ "timestamp": 1497952368055, "status": 404, "error": "Not Found", "message": "No message available", "path": "/health" }

Spring boot version is 1.5.4.RELEASE. And Java 1.8 What additional settings do I need to do ?

Upvotes: 12

Views: 36001

Answers (7)

Omkar Kotibhaskar
Omkar Kotibhaskar

Reputation: 1

Check if you have added a context path.

if yes, you need to try ->

http://localhost:8080/{{serviceName}}/actuator/health

And check the following in either .properties or .yaml file :

  • management.endpoints.web.exposure.include = * : if you want to include all endpoints on actuator
  • management.endpoints.web.exposure.include = health : if you need only health endpoint

Upvotes: 0

Saurabh  Rokade
Saurabh Rokade

Reputation: 1

If still not working for :

  1. Select project the rth click
  2. Run as maven build
  3. Goals - clean install them ok

Upvotes: 0

samivic
samivic

Reputation: 1310

In Spring Boot 2.0.0 you have to use /actuator/health and in the application.properties file add the following line:

management.endpoint.health.show-details=always

Upvotes: 25

Nakul Goyal
Nakul Goyal

Reputation: 659

Add Maven dependency

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

Application.properties

management.endpoints.web.exposure.include= "*" include all endpoints on actuator or management.endpoints.web.exposure.include= health if need only health endpoint

Upvotes: 7

Dheeraj kumar
Dheeraj kumar

Reputation: 77

Maven dependency

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

Application.properties

spring.profiles.active=local
server.port = 9292
management.endpoints.web.exposure.include=env,health,metrics

For reference use below link:(step by step explanation)

https://www.youtube.com/watch?v=0Dj2tsK2V2g

Upvotes: 1

AConsumer
AConsumer

Reputation: 2781

Do the following steps : -

  1. Change the scope of actuator dependency from test to compile

  2. Instead of using /health use /actuator/health

  3. If you want to see details of the health status then addmanagement.endpoint.health.show-details=always in the application.properties file.

Upvotes: 8

Janar
Janar

Reputation: 2701

In your dependency you have declared

<scope>test</scope>

It means that

test

This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.

If you want it available for normal use of the application remove <scope>test</scope> or change it to <scope>compile</scope>

Upvotes: 4

Related Questions