To Do :
- Spring security
- Running actuator on different port
Spring Security https://docs.spring.io/spring-boot/docs/1.5.4.RELEASE/reference/html/production-ready-monitoring.html
- Actuator brings production-ready features to our application
- Monitoring our app, gathering metrics, understanding traffic or the state of our database becomes trivial with it.
- Actuator is mainly used to expose operational information about the running application – health, metrics, info, dump, env, etc. It uses HTTP endpoints or JMX beans to enable us to interact with it.
- Once this dependency is on the classpath several endpoints are available for us out of the box. As with most Spring modules, we can easily configure or extend it in many ways.
To enable SpringBoot actuator we need to add below line in our build.gradle
implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.data:spring-data-rest-hal-browser:2.4.0.RELEASE'
application.propeties
#management.port=9292 #management.security.enabled=false management.endpoint.health.show-details=always management.endpoints.web.exposure.include=* #management.endpoints.web.exposure.include=actuator,auditevents,beans,health,conditions,configprops,info,loggers,heapdump,threaddump,metrics,scheduledtasks,httptrace,mappings,env,health,metrics
When the application the list of actuator endpoints are listen in the console
Here are some of the most common endpoints Boot provides out of the box:
- /health – Shows application health information (a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated); it’s not sensitive by default
- /info – Displays arbitrary application info; not sensitive by default
- /metrics – Shows ‘metrics’ information for the current application; it’s also sensitive by default
- /trace – Displays trace information (by default the last few HTTP requests)
Configure existing endpoints :
Three properties are available:
- id – by which this endpoint will be accessed over HTTP
- enabled – if true then it can be accessed otherwise not
- sensitive – if true then need the authorization to show crucial information over HTTP
For example, add the following properties will customize the /bean endpoint:
endpoints.beans.id=springbeans endpoints.beans.sensitive=false endpoints.beans.enabled=true
URLs :
http://localhost:9090/actuator http://localhost:9090/application
SSL for actuator port :
server.port=8443 server.ssl.enabled=true server.ssl.key-store=classpath:main.jks server.ssl.key-password=secret management.port=8080 management.ssl.enabled=true management.ssl.key-store=classpath:management.jks management.ssl.key-password=secret
Actuator only for OPS i.e local environment ips
management.port=8081 management.address=127.0.0.1 #management.address=localhost
Read Me :
Spring Security in Actuator : https://docs.spring.io/spring-boot/docs/1.5.4.RELEASE/reference/html/production-ready-monitoring.html https://spring.io/guides/gs/actuator-service/