Spring Actuator is the spring based component, which contains features based on spring boot actuator. It helps to monitor and manage application's health and provide features such as status of application, disk information, database status and other statistics. This information can be retrieved by hitting certain endpoints. Only two end points health metrics have been implemented recently by us.
- Health Endpoint : health endpoint provides basic application health information.
- Metrics Endpoint : Shows ‘metrics’ information for the spring application.
Spring boot Actuator module in spring boot framework helps application developers to implement the features like metrics, health check, security, etc. with minimal effort.
Some reference links for spring boot actuator:
- http://www.tutorialspoint.com/articles/spring-boot-actuator-a-production-grade-feature-in-spring-boot
- http://javabeat.net/spring-boot-actuator/
- https://spring.io/guides/gs/actuator-service/
- Your project must be in Spring 4.3.4 RELEASE or above.
- Your project must use MongoDB or Cassandra database.
-
Download springactuator library and install it in your local repository.
mvn clean install -
Download spring-actuator-parent library and install it in your local repository.
mvn clean install -
Add spring-actuator-parent in the tag in the pom.xml in your Spring Application which is to be monitored,so that the required dependencies will be added.
<parent> <groupId>com.azilen.spring</groupId> <artifactId>spring-actuator-parent</artifactId> <version>1.0</version> </parent>
-
Add springactuator dependency in the pom.xml in your Spring Application which is to be monitored,so that the required dependencies will be added.
<dependency> <groupId>com.azilen.spring</groupId> <artifactId>springactuator</artifactId> <version>1.0</version> </dependency>
-
You will require to scan springactuator packages in your application.
-
If your project has xml based configuration add below line
<context:component-scan base-package="com.azilen.spring.*" />
-
Add Spring-admin.properties file in the classpath of the Spring Application which is to be monitored. It should be added in the resources folder.
-
You can configure properties as below
- server.displayName=SpringMVCMongoDBActuator
- spring.boot.admin.url=http://localhost:8081
- info.app.version=This is SpringMVCMongoDBActuator app version
-
We have developed the spring-actuator keeping the following versions
- Spring 4.3.4.RELEASE
- spring-data-mongodb to be 1.9.4.RELEASE
- mongo-java-driver to be 3.2.2
- jackson dependencies to be 2.7.3
- spring-data-couchbase to be 2.1.4.RELEASE
- java-client to be 2.2.8
- spring-data-cassandra to be 1.5.1.RELEASE
-
build war file of your spring application.
-
Copy war file and start the tomcat server.
-
Now our endpoints like health, metrics will be available.
http://localhost:8080/SpringMVCMongoDBActuator/health
{
"status": "UP",
"diskSpace": {
"status": "UP",
"total": 493767094272,
"free": 388059553792,
"threshold": 10485760
},
"mongo": {
"status": "UP",
"version": "3.0.2"
}
}http://localhost:8080/SpringMVCMongoDBActuator/metrics
{
"mem": 916590,
"mem.free": 392988,
"processors": 8,
"instance.uptime": 154170,
"uptime": 167724,
"systemload.average": -1.0,
"heap.committed": 817664,
"heap.init": 131072,
"heap.used": 424675,
"heap": 1844224,
"nonheap.committed": 100800,
"nonheap.init": 2496,
"nonheap.used": 98926,
"nonheap": 0,
"threads.peak": 49,
"threads.daemon": 33,
"threads.totalStarted": 59,
"threads": 49,
"classes": 12175,
"classes.loaded": 12175,
"classes.unloaded": 0,
"gc.ps_scavenge.count": 11,
"gc.ps_scavenge.time": 344,
"gc.ps_marksweep.count": 3,
"gc.ps_marksweep.time": 225,
"httpsessions.max": -1,
"httpsessions.active": 0
}http://localhost:8080/SpringMVCCassandraActuator/health
{
"status": "UP",
"diskSpace": {
"status": "UP",
"total": 493767094272,
"free": 388059525120,
"threshold": 10485760
},
"cassandra": {
"status": "UP",
"version": "3.9.0"
}
}http://localhost:8080/SpringMVCCassandraActuator/metrics
{
"mem": 918075,
"mem.free": 375248,
"processors": 8,
"instance.uptime": 316798,
"uptime": 325635,
"systemload.average": -1.0,
"heap.committed": 817664,
"heap.init": 131072,
"heap.used": 442415,
"heap": 1844224,
"nonheap.committed": 102272,
"nonheap.init": 2496,
"nonheap.used": 100411,
"nonheap": 0,
"threads.peak": 49,
"threads.daemon": 33,
"threads.totalStarted": 67,
"threads": 49,
"classes": 12178,
"classes.loaded": 12178,
"classes.unloaded": 0,
"gc.ps_scavenge.count": 11,
"gc.ps_scavenge.time": 344,
"gc.ps_marksweep.count": 3,
"gc.ps_marksweep.time": 225,
"httpsessions.max": -1,
"httpsessions.active": 0
}-
These end points have been integrated with spring boot admin UI server. Spring admin server needs to be started to view admin server. Automatic registration of application will be done to spring admin server once the admin server is running the Spring Actuator sample.
Spring Admin UI server : http://localhost:8081/
-
Once you click on the details link, Health and Metrics details can be viewed.
- When you click on the details button, metrics details can be viewed

