I m working on a customized health check for an API. Where I m using :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.5.5</version>
</dependency>
and implementing the HealthIndicator interface.
I m wondering if there is a way to get access to the payload returned by /actuator/health ?
so I can desterilize it, and base on the values on the object (payload), I will build the implementation for the heath() method from HealthIndicator Interface.
I have tried to use:
- HealthEndpoint but it needs an implementation for HealtContributorRegistary , not sure how to do that.
- SystemHealth (im getting the error : class Cannot be accessed from outside package).
any help is very welcomed.
Thank you.
I was able to get access to all my API components status by
#Autowired HealthContributor[] healthContributors;
in a service.
I have followed this answer : Direct access to Spring Boot Actuator Health beans/data?
I am trying to expose timing metrics to prometheus from an api implemented with spring boot 2. I've included the following dependencies.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
I'm managing dependencies through spring-cloud-starter-parent Finchley.SR1, which gives me versions of 2.0.4.RELEASE on spring-boot-starter-actuator, and 1.0.6 on micrometer-registry-prometheus.
The /actuator/prometheus endpoint is working and reachable, but the metrics I need are not included. When I look at /acutator/metrics, the "http.server.requests" metric is not listed there:
{
"names": [
"jvm.memory.max",
"cache.eviction.weight",
"cache.gets",
"process.files.max",
"jvm.gc.memory.promoted",
"tomcat.cache.hit",
"system.load.average.1m",
"tomcat.cache.access",
"jvm.memory.used",
"jvm.gc.max.data.size",
"jvm.gc.pause",
"jvm.memory.committed",
"system.cpu.count",
"logback.events",
"tomcat.global.sent",
"jvm.buffer.memory.used",
"tomcat.sessions.created",
"jvm.threads.daemon",
"system.cpu.usage",
"jvm.gc.memory.allocated",
"tomcat.global.request.max",
"tomcat.global.request",
"tomcat.sessions.expired",
"jvm.threads.live",
"jvm.threads.peak",
"tomcat.global.received",
"process.uptime",
"cache.puts",
"cache.size",
"cache.evictions",
"tomcat.sessions.rejected",
"process.cpu.usage",
"tomcat.threads.config.max",
"jvm.classes.loaded",
"jvm.classes.unloaded",
"tomcat.global.error",
"tomcat.sessions.active.current",
"tomcat.sessions.alive.max",
"jvm.gc.live.data.size",
"tomcat.servlet.request.max",
"tomcat.threads.current",
"tomcat.servlet.request",
"process.files.open",
"jvm.buffer.count",
"jvm.buffer.total.capacity",
"tomcat.sessions.active.max",
"tomcat.threads.busy",
"process.start.time",
"tomcat.servlet.error"
]
}
According to documentation, and everything I can find searching google, it should be one of the metrics that is autoconfigured out-of-the-box.
I have tried this with the spring.metrics.web.server.auto-time-requests property set to true, and with #Timed annotations on the endpoint I am testing with, and either way I get nothing.
I found this resolved issue in which someone had the same symptoms, but they were using spring boot 1.5 and their issue was an unneeded extra dependency that I do not have:
Actuator /metrics endpoint does not include http.server.requests
Any idea what would cause actuator to not expose the http.server.requests metric?
I should add that I have 6 other services like this one in which the metrics are working as expected, so it's just this one out of the 7 where it does not work. I can't figure out what is different about this one. I've even tried stripping it down to remove any dependencies that are not also present in the other six, but still this one won't report that metric.
Can you after accessing any one of your end-point? Just give it a try from postman or from your app and check the /metrics endpoint. I hope it should be there.
I've got a small project running Spring Boot and Spring Cloud Streams with version Greenwich.SR4.
So far I've tried to include the following dependency.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>
Wanting to have a /check/health endpoint which basically returns a code 200.
I've modified the config accordingly so that I don't have useless health configs within.
management.endpoints.web.base-path=/check
management.endpoint.health.enabled=true
management.health.solr.enabled=false
management.health.elasticsearch.enabled=false
However, whenever I try to run localhost:8080/check/health a 404 is prompted. What could be happening?
Also mentioning that I've tried including my own #RestController but same behavior happens.
The URL for the health check should be http://localhost:8080/check/health, not /check/status.
It is depends on the Spring-Boot version. After version 2.0 the path name is manage, so your right url is: http://localhost:8080/check/health
You can also change that with (.yml version):
management:
context-path: /manage
security:
enabled: false
Our application is based on Spring-boot 2.0. I've enabled basic security by adding the following dependency to pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
I also have added properties so that I can define my own userid and password for basic security, instead of the generated ones. I defined them like this in /resources/applicaiton.properties file:
security.user.name=user1
security.user.password=pass1
When I startup my application, I can see that is still generates the password for me in the log. Also, I am unable to login using user1/pass1 combination. I can only successfully login with the user=user and password=generated-password-from-log file.
Why won't spring security allow me to login with user1/pass1? What could be the problem?
Those properties need the spring prefix.
spring.security.user.name=user # Default user name.
spring.security.user.password= # Password for the default user name.
If I want to configure something I often take a look at this List
I hope this helps.
Usually I could get a url mapping overview using the url:
/application/mappings
Now I get a
PageNotFound - No mapping found for HTTP request with URI [/application/mappings] in my log and Response Status: 404 (Not Found) in my browser.
Also the other Spring urls /application/autoconfig, /application/beans and /application/configprops give the same problem.
I'm using spring-boot 2.0.0.RELEASE.
The actuator artifact was added to the pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
What am I doing wrong?
According to the current Spring Boot 2.0 documentation the default actuator endpoints are prefixed with /actuator, not with /application. This was different for M4 and I think they've changed it in M7.
M4 docs:
For example, by default, the health endpoint will be mapped to
/application/health.
M7 docs:
For example, by default, the health endpoint is mapped to
/actuator/health