Unable to suppress /health in Spring boot actuator - spring

On my application.properties i have endpoints.enabled=false and also endpoints.health.enabled=false but still the /health endpoint is not getting suppressed.

Maybe you are missing the first level of the properties.
The properties should be configured like this, to disable all endpoints
management.endpoints.enabled-by-default= false
if you only want to disable the health endpoint than use this property:
management.endpoint.health.enabled=false

I think the issues here could be the version of Sprint Boot being used. 1.5.x has different properties to 2.0.x.
Spring Boot 2.0.x
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=false
management.endpoint.info.enabled=true
Spring Boot 1.5.x
endpoints.enabled=false
endpoint.health.enabled=false
endpoint.info.enabled=true
Please also note that when enabling endpoints you use plural ("endpoints") but when enabling a specific endpoint you use a singlton ("endpoint").

Related

How to test a Spring Boot actuator endpoint when the 'server.port' and 'management.server.port' properties are different

I would like to test the /health endpoint of my Spring Boot microservice with the help of the MockMvc bean.
But in my case the server.port and management.server.port properties have different values.
And the GET request issued by my MockMvc always ends on the port defined in server.port.
There is already an answer there : Spring boot's actuator unavailable when set management port
But I cannot find this ManagementContextResolver class in Spring Boot 2.2.2.
So far, I found out that the 'management' ConfigurableWebServerApplicationContext is created in org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration.DifferentManagementContextConfiguration, but I don't see how I can obtain a reference to it..
try this, its from the SpringBoot Docs :
#WebIntegrationTest({"server.port=8080", "management.port=8090"})

Expose cache endpoint from spring-boot-actuator in not a non spring-boot app

I am using non spring-boot app but I need to expose endpoint which will return caches configured in the application. I saw this post but it is for spring-boot-actuator version 1.X and I am using spring-boot-actuator version 2.1.3.RELEASE as the cache endpoint is available in this version.
Have you tried adding the following to the application.yml file?
management:endpoints.web.exposure.include: ["caches", etc....`]
management.endpoint.caches.enabled:true
Did you set actuator endpoint?
management.endpoints.web.base-path // default /actuator
In that case, you should include endpoint to the path.
example
http://localhost:8080/actuator/caches

How to Refresh Spring Boot Configuration Info with Using Spring Cloud Config

I would like to ask how to refresh spring boot configuration info with using spring cloud config. Would you please give me some advice? Many thanks.
If your spring boot application is a client of Spring Cloud Configuration Server and use itself as single point of truth in the application configuration let's say retrieve application.properties/yml from the config server, you can benefit of #RefreshScope. in this case if you do a post to the /refresh if you use spring boot 1.x or /actuator/refresh if you use spring boot 2.x all the bean that are have are annotated as #RefreshScope will be refreshed.

How to disable security on actuator endpoints on spring boot 1.5 with spring security

I have a Spring Boot application with secure API on port 8080, using #EnableWebSecurity annotation. The management port is changed to 8081 and is not exposed to the public so I don't need/want to have security enabled on the actuator endpoints
On Spring Boot 1.4 it was possible to use property management.security.enabled=false to ignore all actuator endpoints from security. I understand that this functionality was considered a "mistake", and Boot 1.5 "corrects" this by removing this auto-configuration if #EnableWebSecurity is present. The release notes state that we have to explicitly configure this ourselves in this case.
Does this mean we have to pull this out of 1.4 source and implement in each app, or is there a new way of achieving this?

How to customize Spring Boot Actuator endpoints

I'm trying to implement Spring Boot Actuator on a non "Boot Application", is there a way to configure a pattern to endpoints like endpoint/health,endpoint/metrics? Then I'll create a second realm in my existing Spring Security configuration, I tried the documentation but I could not find a thing about.
Thanks.
Did you mean management.contextPath=/endpoint (docs here)?

Resources