POM 종속성 추가 :
<!-스프링 부트 모니터링-> <pectionency> <groupId> org.springframework.boot </groupid> <artifactid> Spring-Boot-Starter-Actuator </artifactid> </fexendency> <pectionency> <groupId> org.springframework.boot </groupid> <artifactid> Spring-Boot-Starter-Web </artifactid> </fectionency>
Application.yML에서 모니터링 된 HTTP 포트를 지정하십시오 (지정되지 않은 경우 서버와 동일한 포트); 특정 점검을 제거하도록 지정하십시오 (예 : 건강 모니터링 메일) :
서버 : 포트 : 8083 관리 : 포트 : 8083 보안 : 활성화 : False #
엔드 포인트를 모니터링하고 관리합니다
| 엔드 포인트 이름 | 설명하다 |
|---|---|
| autoconfig | 모든 자동 구성 정보 (POSITIVEMATCHES : 실행, 부정적인 구성 요소를 실행하지 않음) |
| 감사 | 감사 이벤트 |
| 콩 | 모든 Bean 정보 |
| configProps | 모든 구성 속성 |
| 덤프 | 스레드 상태 정보 |
| env | 현재 환경 정보 |
| 건강 | 건강 상태를 적용하십시오 |
| 정보 | 현재 응용 프로그램 정보 |
| 메트릭 | 응용 프로그램의 다양한 지표 |
| 매핑 | @requestmapping 맵 경로를 적용하십시오 |
| 일시 휴업 | 현재 응용 프로그램 닫기 (기본적으로 닫기) |
| 추적하다 | 정보 추적 (최신 HTTP 요청) |
| heapdump | 메모리 스냅 샷을 다운로드하십시오 |
http : // localhost : 8083/info 정보 읽기* 구성 파일 응용 프로그램의 속성 .properties
InfoProperties에서 읽으십시오
Application.properties :
info.app.version = v1.2.0info.app.name = abc
gitproperties에서 git.properties 정보를 얻으십시오
info.app.version = v1.2.0info.app.name = abc #원격으로 닫히고 enable endpoints.shutdown.enabled = true #access : http : // localhost : 8083/종료 서비스
메트릭
{mem : 57349, // 메모리 크기 mem.free : 388198, // 메모리 나머지 크기 프로세서 : 4, // 프로세서 수 인스턴스 uptime : 338426, 가동 시간 : 345091, Systemload.average : -1, heap.committed : 489984, heap.init : 131072, heap. 1842688, nonheap.committed : 85056, nonheap.init : 2496, nonheap.used : 83566, nonheap : 0, threads.peak : 46, streshs.daemon : 36, streads.totalstarted : 72, 스레드 : 39, // 스레드 클래스 : 12109, classs // 언로드 클래스 gc.ps_scavenge.count : 10, gc.ps_scavenge.time : 103, gc.ps_marksweep.count : 3, gc.ps_markseep.time : 219, httpsessions.max : -1, httpsessions.active : 0, gue.respessions.mappings : 3, gege. 4, Gauge.Response.Trace : 167, Coun 사용자 정의 구성 지침 :
#메트릭 함수 endpoints.metrics.enabled = false#셀러 다운 원격 종료 엔드 포인트 .Shutdown.enabled = true#set beansidendpoints.beans.id = mybean#set bean#set bean the endpoints.beans.path =/bean#닫기 콩 기능 엔드 포인트. endpoints.beans.enabled = true#모든 액세스 추가 루트 디렉토리 관리 .context-path =/manage management.port = 8181
org.springframework.actuate.Health 패키지에는 Redisheallindicator와 같은 모든 건강 상태 검사가 포함되어 있으며 Redis 스타터가있을 때 확인됩니다.
{status : "down", // status diskspace : {status : "up", 총 : 총 : 395243941888, 무료 : 367246643200, 임계 값 : 10485760}, 토끼 : {status : "down", 오류 : "org.springframework.amqpconnectexection : java.net.net.nectection : java.net.connection :"down " 거부 : "}, redis : {status :"up ", 버전 :"4.0.9 "}, db : {status :"up ", 데이터베이스 :"mysql ", hello : 1}}맞춤형 건강
• 맞춤형 건강 상태 표시기
• 1. HealthIndicator 인터페이스를 구현하기위한 표시기를 작성하십시오
• 2. 표시기 xxxxHealthIndicator의 이름
• 3. 컨테이너에 추가하십시오
import org.springframework.actuate.acealth.health.Health; import org.springframework.actuate.acled.Health.HealthIndicator; import org.springframework.stereotyp.component; @componentpublic class myapphealdicator { @healthindicator { @healthride health () {customized tetho () Health Return Health.down (). WeidDetail ( "MSG", "Service Exception"). Build (); }}요약
위의 것은 편집자가 소개 한 Spring Boot Starter Actuator (Health Monitoring)를위한 구성 및 사용 자습서입니다. 나는 그것이 당신에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!