I always prefer to provide context path with the base URL of application. Now to configure actuator we should include below dependency into our pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
let it use the default version which is being beared by Spring boot version.
Put below properties into your application.properties
server.servlet.contextPath=/<app-name>
server.port=8080
management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.security.enabled=false
management.health.mongo.enabled=false
management.health.redis.enabled=false
management.health.rabbit.enabled=false
management.endpoint.health.show-details=always
#/metrics endpoint configuration
endpoints.metrics.id=metrics
endpoints.metrics.sensitive=false
endpoints.metrics.enabled=true
#/health endpoint configuration (Comment when you are using customized health check)
endpoints.health.id=health
endpoints.health.sensitive=false
endpoints.health.enabled=true
info.app.name=@project.name@
info.app.description=@project.description@
info.app.version=@project.version@
info.app.encoding=@project.build.sourceEncoding@
info.app.java.version=@java.version@
After above configuration once you start your server , you can easily check the metrics as below http calls-
# curl http://localhost:8080/myapp/actuator/metrics
{
"names": ["jvm.buffer.memory.used", "jvm.gc.memory.allocated",
"jvm.memory.committed", "jvm.memory.used", "http.server.requests",
"jvm.gc.max.data.size", "logback.events", "system.cpu.count",
"jvm.memory.max", "jvm.buffer.total.capacity", "jvm.buffer.count",
"process.files.max", "jvm.threads.daemon", "process.start.time",
"jvm.gc.live.data.size", "process.files.open", "process.cpu.usage",
"process.uptime", "system.load.average.1m", "jvm.gc.pause",
"system.cpu.usage", "jvm.threads.live", "jvm.classes.loaded",
"jvm.classes.unloaded", "jvm.threads.peak", "jvm.gc.memory.promoted"]
}
For details you can watch my blog here