spring boot 經過actuator 來提供應用服務器信息。例如能夠經過health 查看存儲信息,服務器是否正常運行 經過metrics能夠觀察heap, mem等信息。 方便用戶監控應用html
1 在pom.xml 添加actuator 依賴java
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
2 在application.properties 配置詳細信息spring
management.context-path=/manage endpoints.health.sensitive=false endpoints.metrics.sensitive=false endpoints.info.sensitive=false management.context-path=/manage endpoints.health.sensitive=false endpoints.metrics.sensitive=false endpoints.info.sensitive=false #config info details info.app.name=MyApp info.app.description=descript for the project info.build.groupId=@project.groupId@ info.build.artiface=@project.artifactId@ info.build.version=@project.version@ info.app.encoding=@project.build.sourceEncoding@ info.app.java.source=@java.version@ info.app.java.target=@java.version@
3 測試這裏我配置了/manage 爲actuator的根路徑服務器
輸入localhost:8080/manage/healthsession
{"status":"UP","diskSpace":{"status":"UP","total":255534821376,"free":107373064192,"threshold":10485760},"db":{"status":"UP","database":"Oracle","hello":"Hello"}}
輸入localhost:8080/manage/metricsapp
{"mem":374672,"mem.free":112188,"processors":4,"instance.uptime":182778,"uptime":199229,"systemload.average":-1.0,"heap.committed":310272,"heap.init":253952,"heap.used":198083,"heap":3592192,"nonheap.committed":66176,"nonheap.init":2496,"nonheap.used":64401,"nonheap":0,"threads.peak":33,"threads.daemon":31,"threads.totalStarted":40,"threads":33,"classes":7965,"classes.loaded":7967,"classes.unloaded":2,"gc.ps_scavenge.count":12,"gc.ps_scavenge.time":233,"gc.ps_marksweep.count":2,"gc.ps_marksweep.time":139,"httpsessions.max":-1,"httpsessions.active":0,"gauge.response.star-star":12.0,"gauge.response.manage.health":935.0,"counter.status.404.star-star":2,"counter.status.200.manage.health":1}