Actuator - SirajChaudhary/comprehensive-example-on-microservices-using-spring-boot-with-spring-cloud GitHub Wiki
Actuator
- spring-boot-actuator module provides production-ready features for your microservice such as health check-up, auditing, metrics gathering, HTTP tracing, env, etc.
- It uses HTTP or JMX endpoints to expose operational information about any running microservice. You can enable or disable each individual endpoint.
- It provides a number of built-in endpoints and lets you add your own.
Steps to setup spring-boot-actuator module into your spring-boot microservice
Step1: Add actuator maven dependency in pom.xml
<!-- spring boot starter actuator -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Step2: Add different actuator properties in application.yml
# ACTUATOR WEB ENDPOINTS EXPOSURE
management:
  endpoints:
    web:
      exposure:
        # EXPOSE ALL THE ACTUATOR WEB ENDPOINTS IF SECURITY IS NOT YOUR CONCERN!
        include: "*"
    # CORS LETS YOU SPECIFY WHAT CROSS DOMAIN REQUESTS ARE AUTHORIZED.
    # CORS SUPPORT IS DISABLED BY DEFAULT AND TO ENABLE IT SET FOLLOWING PROPERTIES. 
    # https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html
    cors:
      allowed-origins: http://localhost:2021
      allowed-methods: GET,POST,PUT,DELETE
  # GET DETAIL INFORMATION OF ACTUATOR HEALTH ENDPOINT 
  endpoint:    
    health:
      show-details: always
# ACTUATOR WEB INFO ENDPOINT OF THIS MICROSERVICE
# E.g. You can get info endpoint with this URL http://localhost:2021/airport-pilot-service/actuator/info
info:
  name: Aiport Pilot Service
  description: Its a microservice for pilot service
  author: Siraj Chaudhary
Step3: We can hit various actuator provided built-in endpoints now to monitor different metrics and all of our microservice
actuator-output1
actuator-output2
actuator-output3
actuator-output4
actuator-output5
actuator-output6
actuator-output7 Here is how we create our own custom actuator endpoint
actuator-output8
Reference
https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html