Spring-Actuator는 애플리케이션 모니터링을위한 스프링 부츠의 통합 모듈입니다. 서버 모니터링을 지원하여 응용 프로그램에로드 된 응용 프로그램 구성, 환경 변수, 자동 구성 보고서 등을보다 직관적으로 얻을 수 있습니다.
스프링 액츄에이터 사용
1. Maven 의존성을 소개합니다
<!-모니터링 및 관리 모듈-> <pectionency> <groupId> org.springframework.boot </groupid> <artifactid> 스프링 보트-스타터-액투터 </artifactid> </dependency>
종속성을 도입 한 후 프로젝트를 시작하십시오.
프로젝트가 시작되면 필요한 URL이 인쇄됩니다.
2018-03-26 23 : 19 : 00.169 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/env/ {name:.*}}}, methods= [get], productes= [application/vnd.spring-boot.actuator.v1+json | java.lang.object org.springframework.boot.actuate.endpoint.mvc.environmentmvcendpoint.value (java.lang.string)
2018-03-26 23 : 19 : 00.169 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/ENV ||/ENV.JSON ],METHODS= [GEGT 개발 ],Produces= [Application/vnd.spring-boot.actuator.v1+json || java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.170 Info 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/TRACE || /trace.json ],Methods= [Get], ProductionS= [Application/vnd.spring-boot.actuator.v1+json || on on on on on on public | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.170 Info 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/DUMP || /dump.json ],Methods= [Get], Produces= [Application/vnd.spring-boot.actuator.v1+json || on on on on on on on on on on on on on on one vere java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.171 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/AUDITEVENTS ||/auditeVents.json ],Methods= [get], application/vnd.spring-boot.actuator.v1+JSON | org.springframework.http.responseentity <?> org.springframework.actuate.endpoint.mvc.auditeventsmvcendpoint.findbyprincalandafterandtype (java.lang.string, java.util.date, java.lang.string)
2018-03-26 23 : 19 : 00.171 Info 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/MAPPINGS || /MAPPINGS.JSON ],METHODS= [get], producticatem=] application/vnd.spring-boot.actuator.v1+ JSON | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.172 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/autoconFig ||/aUtoconfig.json] get] get ter on on on on on on on on on on on on on on on on on onectuces | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.173 Info 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/metrics/ {name:.*} },Methods= [get], production= [application/vnd.spring-boot.actuator.v1 volson || java.lang.object org.springframework.boot.actuate.endpoint.mvc.metricsmvcendpoint.value (java.lang.string)
2018-03-26 23 : 19 : 00.173 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/metrics || /metrics.json ],methods========== [application/vnd.spring-boot.actuator.v1+ JSON || java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.173 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPD "{[ /pause || /pause.json], methods=]}"공개 java.lang.object org.springframework.cloud.endpoint.genericepostberpostpospostpostspostspostspostpest.indpoint.generice
2018-03-26 23 : 19 : 00.174 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : 매핑 "{[/service-registry/instance-status], methods = [post]}"public org.springframework.http.respontity <?> org.springframework.cloud.client.serviceregistry.endpoint.serviceregistryendpoint.setstatus (java.lang.string)
2018-03-26 23 : 19 : 00.174 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : 매핑 "{[/service-registry/instance-status], methods = [get]}"공개 org.springframework.http.respontity. org.springframework.cloud.client.serviceregistry.endpoint.serviceregistryendpoint.getstatus ()
2018-03-26 23 : 19 : 00.175 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/Loggers/ {name:.*} ],Methods= [get], production/vnd.spring-boot.actuator.v1+ JSON || java.lang.object org.springframework.actuate.endpoint.mvc.loggersmvcendpoint.get (java.lang.string)
2018-03-26 23 : 19 : 00.175 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/Loggers/ {name:.*} ],Methods= ],Consumes=] application/vnd.spring-boot.actuator.v1+ JSON | | Application/JSON], 생산 = [Application/vnd.spring-boot.actuator.v1+JSON || java.lang.string>)
2018-03-26 23 : 19 : 00.175 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/loggers || /loggers.json ],methods= [get], application/vnd.spring-boot.actuator.v1 | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.176 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPED "{[/heapDump || /HeapDump.json ],Methods= [get]은 공개 void에 대한 프로듀서들에 대한 프로듀서들에게 공개적 org.springframework.actuate.endpoint.mvc.heapdumpmvcendpoint.invoke (boolean, javax.servlet.http.httpservletrequest, javax.servlet.http.httpervletresponse) java.io.ioexception, javax.servletecection
2018-03-26 23 : 19 : 00.176 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[ /reforme || /refresh.json], methods=]}"공개 java.lang.object org.springframework.cloud.nendpoint.genericepostberpostpostspostspost에 공개 java.lang.object org.springframework.nendpoint.generice
2018-03-26 23 : 19 : 00.177 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[ /recume || /resume.json], methods=]}"public java.lang.object org.springframework.cloud.endpoint.genericepostberpostpospostpospostpospostpospostpospostpospostpopte.
2018-03-26 23 : 19 : 00.178 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/configProps || /configProps.json], Methods= [get]은 application/json | on | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.178 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/archaius ||/archaius.json ],methods= [get], producticatem/vnd.spring-boot.actuator.v1+ JSON | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.179 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/HEALTH || /HEALTH.JSON ],METHODS= [GEGT 개발 ],Produces= [Application/vnd.spring-boot.actuator.v1+json || on on on on on on on on on on on on on on one vere java.lang.object org.springframework.boot.actuate.endpoint.mvc.healthmvcendpoint.invoke (javax.servlet.http.httpervletrequest, java.security.principal)
2018-03-26 23 : 19 : 00.179 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPED "{[/ENV], Methods = [Post]}"공개 java.lang.object에 "" org.springframework.cloud.context.environment.environmentmanagermvcendpoint.value (java.util.map <java.lang.string, java.lang.string>)
2018-03-26 23 : 19 : 00.179 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPD "{[/ENG/RESET], Methods = [Post]}"공개 java.util.map <java.lang.string, java.lang.object> org.springframework.cloud.context.environment.environmentmanagermvcendpoint.reset ()
2018-03-26 23 : 19 : 00.179 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/feature || /features.json ],Methods= [Get], productes= [application/vnd.spring-boot.actuator.v1+Json | on on on on on on on on on on on on public. java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.180 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPED "{[ /RESTART || /RestART.JSONey" org.springframework.cloud.context.restart.restartmvcendpoint.invoke ()
2018-03-26 23 : 19 : 00.181 정보 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMAPPING : MAPPAPP "{[/ENTITY ||/entity.json], Methods= [get 개발], production= [application/vnd.spring-boot.actuator.v1+json | java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.181 Info 6148 --- [Main] OSBAEMVC.ENDPOINTHANDLERMPAPP : MAPPAPP "{[/info || /info.json], Methods= [GetT], production= [application/vnd.spring-boot.actuator.v1+Json | on on on on on on on on on on publice. java.lang.object org.springframework.actuate.endpoint.mvc.endpointmvcadapter.invoke ()
2018-03-26 23 : 19 : 00.193 Info 6148 --- [Main] SWSMMAREQUESTMAPPING HANDLERMAPPING : MAPPED "{[/ERROR]}"공개 java.util.map <java.lang.string, java.lang.object> org.springframework.actuate.endpoint.mvc.managementerRorendpoint.invoke ()
2. YML 구성 파일 구성
(1) 포트 번호를 구성하고 특정 기능 모듈을 활성화하지 않습니다.
#포트 번호를 개발하지 않으면 서버 서버와 동일합니다. 포트 관리 : 포트 : 4321 #콘텐츠를 볼 필요가없는 함수를 제거합니다.
위의 구성은 구성된 포트가 HTTP 포트 4321이고 /건강 기능이 비활성화되었음을 나타냅니다.
(2) 매핑 경로를 수정하십시오
#구성 Endpoints의 매핑 ID 경로를 수정 : Beans : ID : 엔티티
위의 구성은 /콩으로 /콩으로 콩을 생성하는 경로를 변경하는 것을 의미합니다.
(3) 액추에이터 보안 구성을 구성합니다
스프링 보안이 필요합니다
종속성을 소개합니다
<!-등록 센터 액세스 계정 인증-> <pectomency> <groupId> org.springframework.boot </groupid> <tritifactid> 스프링-부트 스타터-보안 </artifactid> </dependency>
계정 비밀번호 구성 :
보안 : 기본 : #계정 비밀번호 인증 활성화를 활성화하기 위해 #Represents : True #Configure 계정 및 비밀번호 사용자 : 이름 : 루트 비밀번호 : 123
계정 비밀번호를 구성한 후 http://127.0.0.1:4321을 통해 액세스하고 구성된 계정 및 비밀번호를 입력 할 수 있습니다. 브라우저가 한 번 닫히지 않으면 유효합니다.
(4) 디스플레이 메시지를 JSON 형식으로 표시합니다
JSON 형식 디스플레이는 더 나은 가독성과 미학을 가지고 있습니다
#acyuator에 의해 JSON 형식으로 표시된 패킷을 인쇄 : Jackson : Serialization : Indent-Output : True
Application.yml 파일에 위 구성을 추가하십시오
3. 시작 클래스 구성
@springbootApplication@enableeureKaserver //이 줄 주석은 서비스의 등록 구성 요소를 나타냅니다. 이 주석은 eureKapublic class eureKaserVerApplication {public static void main (String [] args) {springApplication.run (eureKaserVerApplication.class, args)에만 적용됩니다. }}구성없이 실행하십시오
4. 일부 주요 구성 모듈
| HTTP 요청 방법 | 길 | 설명하다 |
| 얻다 | /autoconfig | 응용 프로그램에 대한 자동 구성 정보를 얻는 데 사용됩니다 |
| 얻다 | /콩 | 응용 프로그램 컨텍스트에서 모든 콩을 생성하는 데 사용됩니다. |
| 얻다 | /configProps | 애플리케이션에서 구성된 속성 정보 보고서를 가져옵니다 |
| 얻다 | /env | 응용 프로그램에 대한 모든 환경 변수 속성 보고서를 얻는 데 사용됩니다. |
| 얻다 | /매핑 | 모든 SpringMVC를 얻기위한 컨트롤러 매핑 관계 보고서 |
| 얻다 | /정보 | 응용 프로그램 사용자 정의 정보를 얻는 데 사용됩니다 |
(1) /autoconfig
이 구성에는 두 개의 마스터 노드가 있습니다.
positiveMatches : 성공적인 조건 일치를 위해 자동 구성 정보를 반환합니다
NegativeMatches : 조건 일치가 실패한 구성 정보를 반환합니다.
(2) /콩
이 구성 파일은 다음 노드를 포함하여 ApplicationContext Application 컨텍스트에서로드 된 Bean 객체를 표시하는 데 사용됩니다.
"context": "bootstrap", "parent": null, "beans": [{ "bean": "propertySourceBootStrapConfiguration", "aliases": [], "scope": "Singleton", "type": "type": "org.springframework.cloud.bootstrap.config.propertysourcebootstrapconfiguration $$ EnhancerByspringcglib $$ 82fdf928", "resource": "null", "dependencies": []}]Beans는 응용 프로그램 컨텍스트에로드 된 클래스 모음이며, 여기에는 다음 태그가 포함됩니다.
1), Bean : 응용 프로그램 컨텍스트에 의해 생성 된 콩의 이름
2) 범위 : 생성 된 콩의 범위
싱글 톤 : 싱글 톤은 스프링의 기본 범위입니다
프로토 타입 : 각 요청은 새 인스턴스가 생성되며 새로운 인스턴스가 생성됩니다.
요청 : 각 HTTP 요청은 새 인스턴스를 생성하고 현재 Bean은 동일한 httprequest에서만 유효합니다.
세션 : 동일한 httpsession에서 유효합니다
3), 유형 : 상황 관리에 사용되는 콩의 유형
클래스의 자격을 갖춘 클래스 이름
4) 리소스 : 클래스 파일의 특정 경로
5) 종속성 : 종속성 Bean의 이름, 즉 콩에 관련 콩의 이름
(3) /configProps : 애플리케이션에서 구성된 속성 정보 보고서 가져 오기
아래에는 두 개의 자식 노드가 있습니다
접두사 : 속성에 대한 접두사를 구성합니다
속성 : 각 속성의 이름과 값을 나타냅니다
(4) /ENV는 환경 변수, JVM 속성, 응용 프로그램 구성 정보, 명령 줄의 매개 변수 등과 같은 응용 프로그램 컨텍스트의 환경 변수 속성 보고서를 얻는 데 사용됩니다.
1) Server.ports는 응용 프로그램에서 구성하는 포트 번호를 나타냅니다.
2) SystemProperties는 응용 프로그램에 대한 JVM 및 기타 정보를 얻습니다.
(5) /매핑 스프링 MVC 컨트롤러 매핑 보고서,
{ "{[/error]}": { "bean": "requestMappingHandlerMpapping", "method": "public org.springframework.http.responseentity <java.util.map <java.lang.string, java.lang.object >> org.springframework.boot.autoconfigure.web.basicerrorcontroller.error (javax.servlet.http.httpservletrequest) "}}1) /오류는 SpringMVC의 매핑 경로를 나타냅니다
2) /Bean은 프로세서 매퍼 매핑에 사용되는 클래스를 나타냅니다.
3) /메소드는 매핑 클래스의 메소드를 나타냅니다
(6) 정보는 Application.yml에서 구성된 사용자 정의 구성 정보를 얻는 데 사용됩니다.
5. 메트릭 구성
메트릭이 제공하는 보고서 내용은 동적으로 변경되었으며 일부 스냅 샷 정보를 제공합니다. 메모리 사용, HTTP 요청 계산, 외부 리소스 지표 통계 등과 같은 등.
(1) /메트릭은 현재 적용된 다양한 중요한 메트릭을 반환합니다. 다음 내용이 있습니다
1) 시스템 정보 : 프로세서 --- 프로세서 수
인스턴스 .uptime ------ 실행 시간
SystemLoad.Average -시스템 시스템 부하 평균 등
2), men.* : 시스템 메모리 요약 정보
3), 힙* : 힙 메모리 사용
4)
5) 스레드.*: 스레드 사용
6) 클래스.*: 클래스 로딩 및 언로드 상황
7), GC.* : 쓰레기 수집가의 세부 사항
8), httpsession.* : Tomcat과 같은 컨테이너의 그림 상태
9), magage.*: 지연 시간 등과 같은 매핑 값을 반환합니다.
10), conter.* : 카운터로 사용되면 증가 및 감소 양이 기록됩니다.
(2) /건강 : 다양한 건강 지표
메모리에 대한 일부 정보는 다음과 같습니다.
"디스크 스페이스": { "상태": "UP", "Total": 21475880960, "무료": 8916258816, "임계 값": 10485760}(3) /덤프 : 프로그램에서 스레드 정보를 노출시키는 데 사용
ThreadName- 노출 된 스레드 이름입니다
ThreadId- 노출 된 스레드 ID 등
(4) /추적 : 기본 HTTP 정보를 추적하는 데 사용됩니다
6. 작동 제어 클래스 구성
(1) /Shutdowm은 응용 프로그램의 원격 작업을 닫는 데 사용됩니다.
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.