====== Spring Boot Actuator ======
* [[springframework:springboot|SpringBoot]] 관련 애플리케이션 Metric을 제공해준다.
* **actuator** 정보를 외부에 노출해서는 절대로 안된다.** 운영 웹서버에서는 방화벽으로 막거나, HTTP가 아닌 다른 방식으로 노출 방식을 바꾸고, 외부에는 HTTP/HTTPS 포트만 노출시켜야 한다.
* [[http://www.baeldung.com/spring-boot-actuators|Spring Boot Actuators]]
* [[http://www.javabeat.net/spring-boot-actuator/|Complete Guide for Spring Boot Actuator]]
===== 모든 Actuator 켜기 / 끄기 =====
* 기본적으로 info, health 정도만 켜져 있음.
management.security.enabled=false # 전체 다 활성화
management.server.port=8081
management.server.address=127.0.0.1
management.server.port=-1 # http endpoint 끄기
===== Health Check =====
* [[https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#_writing_custom_healthindicators|Writing CUstom Health Indicators]]
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;
@Component
public class MyHealthIndicator implements HealthIndicator {
@Override
public Health health() {
int errorCode = check(); // perform some specific health check
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build();
}
}
* [[https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/common-application-properties.html|Common Application Properties]]에서 ''management.health'' 참고.
===== 참조 =====
* [[https://www.baeldung.com/spring-boot-actuators|Spring Boot Actuator | Baeldung]]
* [[https://brunch.co.kr/@springboot/99|Spring Boot Actuator Metrics]]
* [[https://console.bluemix.net/docs/java/spring-metrics.html#spring-metrics|Metrics with Spring]]
* [[https://spring.io/blog/2018/03/16/micrometer-spring-boot-2-s-new-application-metrics-collector|Micrometer: Spring Boot 2's new application metrics collector]]
* [[https://www.popit.kr/spring-actuator-%EA%B8%B0%EC%B4%88-%EC%84%A4%EC%A0%95-intellij-%ED%99%9C%EC%9A%A9%ED%95%98%EA%B8%B0/|Spring Actuator 기초 설정 & IntelliJ 활용하기 | Popit]]
* [[https://www.baeldung.com/spring-boot-health-indicators?utm_medium=feed|Health Indicators in Spring Boot | Baeldung]]
* [[https://javatechonline.com/how-to-monitor-spring-boot-microservices-using-elk-stack/|How to monitor Spring Boot Microservices using ELK Stack? | Making Java easy to learn]]
* [[https://techblog.woowahan.com/9232/|🍀 Actuator 안전하게 사용하기 | 우아한형제들 기술블로그]]