Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot actuator MySQL database health check

I have designed one demo spring boot application CRUD operation with MySQL database. My application.properties file is as follow.

spring.boot.admin.url=http://localhost:8081
spring.datasource.url= jdbc:mysql://localhost:3306/springbootdb
spring.datasource.username=root
spring.datasource.password=admin
endpoints.health.sensitive=false
management.health.db.enabled=true
management.health.defaults.enabled=true
management.health.diskspace.enabled=true
spring.jpa.hibernate.ddl-auto=create-drop

POM.xml for the spring actuator is as follow.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>1.3.4</version>
</dependency>

When I try to hit the url "http://localhost:8080/health", I am getting {"status":"UP"} as response. I want to monitor my database (MySQL) with spring boot actuator. I want see my database status.

Can anyone please help ?

like image 852
Harshil Avatar asked Sep 22 '16 06:09

Harshil


2 Answers

Add this configuration to your application.properties file

management.endpoint.health.show-details=always 
like image 186
erdinc Avatar answered Sep 19 '22 19:09

erdinc


In spring version 2.2.x is:

management.endpoint.health.show-details=always

by default this prop has value never.

like image 34
nekperu15739 Avatar answered Sep 20 '22 19:09

nekperu15739