SpringBoot之actuator

在springBoot中集成actuator可以很方便的管理和监控应用的状态。

暴露的Restful接口有:

HTTP方法路径描述鉴权
GET /autoconfig 查看自动配置的使用情况 true
GET /configprops 查看配置属性,包括默认配置 true
GET /beans 查看bean及其关系列表 true
GET /dump 打印线程栈 true
GET /env 查看所有环境变量 true
GET /env/{name} 查看具体变量值 true
GET /health 查看应用健康指标 false
GET /info 查看应用信息 false
GET /mappings 查看所有url映射 true
GET /metrics 查看应用基本指标 true
GET /metrics/{name} 查看具体指标 true
POST /shutdown 关闭应用 true
GET /trace 查看基本追踪信息 true

其中有不少请求需要鉴权才能访问,由于我们的应用基本都是在通过Nginx暴露给外网的,我们可以在配置文件禁用鉴权拦截。

# 禁用actuator管理端鉴权
management.security.enabled=false
# 启用shutdown   host:port/shutdown
endpoints.shutdown.enabled=true
# 禁用密码验证
endpoints.shutdown.sensitive=false

通过访问http://IP:port/metrics可以得到类似如下信息:

  1 {
  2     "mem": 372386,
  3     "mem.free": 129077,
  4     "processors": 4,
  5     "instance.uptime": 12149,
  6     "uptime": 20629,
  7     "systemload.average": -1.0,
  8     "heap.committed": 302080,
  9     "heap.init": 129024,
 10     "heap.used": 173002,
 11     "heap": 1807872,
 12     "nonheap.committed": 72448,
 13     "nonheap.init": 2496,
 14     "nonheap.used": 70307,
 15     "nonheap": 0,
 16     "threads.peak": 57,
 17     "threads.daemon": 53,
 18     "threads.totalStarted": 64,
 19     "threads": 55,
 20     "classes": 9724,
 21     "classes.loaded": 9724,
 22     "classes.unloaded": 0,
 23     "gc.ps_scavenge.count": 11,
 24     "gc.ps_scavenge.time": 151,
 25     "gc.ps_marksweep.count": 2,
 26     "gc.ps_marksweep.time": 242,
 27     "counter.servo.eurekaserver.replication.batchsize.count": 0,
 28     "counter.servo.eurekaserver.replication.batchsize.totaltime": 0,
 29     "gauge.servo.eurekaserver.replication.batchsize.stddev": 0.0,
 30     "gauge.servo.eurekaserver.replication.batchsize.percentile_50": 0.0,
 31     "gauge.servo.eurekaserver.replication.batchsize.percentile_95": 0.0,
 32     "gauge.servo.eurekaserver.replication.batchsize.percentile_99": 0.0,
 33     "gauge.servo.eurekaserver.replication.batchsize.percentile_99_50": 0.0,
 34     "counter.servo.eurekaserver.replication.acceptedtasks": 0,
 35     "counter.servo.eurekaserver.replication.replayedtasks": 0,
 36     "counter.servo.eurekaserver.replication.expiredtasks": 0,
 37     "counter.servo.eurekaserver.replication.overriddentasks": 0,
 38     "counter.servo.eurekaserver.replication.queueoverflows": 0,
 39     "gauge.servo.eurekaserver.replication.acceptorqueuesize": 0,
 40     "gauge.servo.eurekaserver.replication.pendingjobrequests": 1,
 41     "gauge.servo.eurekaserver.replication.availablejobs": 0,
 42     "gauge.servo.eurekaserver.replication.reprocessqueuesize": 0,
 43     "gauge.servo.eurekaserver.replication.queuesize": 0,
 44     "counter.servo.count": 0,
 45     "counter.servo.count-minus-replication": 0,
 46     "counter.servo.eurekaserver.replication.executiontime.count": 0,
 47     "counter.servo.eurekaserver.replication.executiontime.totaltime": 0,
 48     "gauge.servo.eurekaserver.replication.executiontime.stddev": 0.0,
 49     "gauge.servo.eurekaserver.replication.executiontime.percentile_50": 0.0,
 50     "gauge.servo.eurekaserver.replication.executiontime.percentile_95": 0.0,
 51     "gauge.servo.eurekaserver.replication.executiontime.percentile_99": 0.0,
 52     "gauge.servo.eurekaserver.replication.executiontime.percentile_99_50": 0.0,
 53     "counter.servo.eurekaserver.replication.numberofsuccessfulexecutions": 0,
 54     "counter.servo.eurekaserver.replication.numberoftransienterrors": 0,
 55     "counter.servo.eurekaserver.replication.numberofpermanenterrors": 0,
 56     "normalized.servo.serialize-all.totaltime": 0.0,
 57     "normalized.servo.serialize-all.count": 0.0,
 58     "gauge.servo.serialize-all.min": 0.0,
 59     "gauge.servo.serialize-all.max": 0.0,
 60     "normalized.servo.serialize-all-delta.totaltime": 0.0,
 61     "normalized.servo.serialize-all-delta.count": 0.0,
 62     "gauge.servo.serialize-all-delta.min": 0.0,
 63     "gauge.servo.serialize-all-delta.max": 0.0,
 64     "normalized.servo.serialize-all_remote_region.totaltime": 0.0,
 65     "normalized.servo.serialize-all_remote_region.count": 0.0,
 66     "gauge.servo.serialize-all_remote_region.min": 0.0,
 67     "gauge.servo.serialize-all_remote_region.max": 0.0,
 68     "normalized.servo.serialize-all-delta_remote_region.totaltime": 0.0,
 69     "normalized.servo.serialize-all-delta_remote_region.count": 0.0,
 70     "gauge.servo.serialize-all-delta_remote_region.min": 0.0,
 71     "gauge.servo.serialize-all-delta_remote_region.max": 0.0,
 72     "normalized.servo.serialize-one.totaltime": 0.0,
 73     "normalized.servo.serialize-one.count": 0.0,
 74     "gauge.servo.serialize-one.min": 0.0,
 75     "gauge.servo.serialize-one.max": 0.0,
 76     "normalized.servo.serialize-one-vip.totaltime": 0.0,
 77     "normalized.servo.serialize-one-vip.count": 0.0,
 78     "gauge.servo.serialize-one-vip.min": 0.0,
 79     "gauge.servo.serialize-one-vip.max": 0.0,
 80     "normalized.servo.compress-payload.totaltime": 0.0,
 81     "normalized.servo.compress-payload.count": 0.0,
 82     "gauge.servo.compress-payload.min": 0.0,
 83     "gauge.servo.compress-payload.max": 0.0,
 84     "gauge.servo.responsecachesize": 0,
 85     "counter.servo.discovery-peernodeclient-localhost_reuse": 0,
 86     "counter.servo.discovery-peernodeclient-localhost_createnew": 0,
 87     "counter.servo.discovery-peernodeclient-localhost_request": 0,
 88     "counter.servo.discovery-peernodeclient-localhost_release": 0,
 89     "counter.servo.discovery-peernodeclient-localhost_delete": 0,
 90     "normalized.servo.discovery-peernodeclient-localhost_requestconnectiontimer.totaltime": 0.0,
 91     "normalized.servo.discovery-peernodeclient-localhost_requestconnectiontimer.count": 0.0,
 92     "gauge.servo.discovery-peernodeclient-localhost_requestconnectiontimer.min": 0.0,
 93     "gauge.servo.discovery-peernodeclient-localhost_requestconnectiontimer.max": 0.0,
 94     "normalized.servo.discovery-peernodeclient-localhost_createconnectiontimer.totaltime": 0.0,
 95     "normalized.servo.discovery-peernodeclient-localhost_createconnectiontimer.count": 0.0,
 96     "gauge.servo.discovery-peernodeclient-localhost_createconnectiontimer.min": 0.0,
 97     "gauge.servo.discovery-peernodeclient-localhost_createconnectiontimer.max": 0.0,
 98     "gauge.servo.connectioncount": 0,
 99     "gauge.servo.localregistrysize": 0,
100     "gauge.servo.numofreplicationsinlastmin": 0,
101     "gauge.servo.isbelowrenewthreshold": 0,
102     "gauge.servo.numofrenewsinlastmin": 0,
103     "gauge.servo.numofrenewsperminthreshold": 1,
104     "gauge.servo.numofelementsininstancecache": 0,
105     "normalized.servo.eureka-connection-cleaner-time.totaltime": 0.0,
106     "normalized.servo.eureka-connection-cleaner-time.count": 0.0,
107     "gauge.servo.eureka-connection-cleaner-time.min": 0.0,
108     "gauge.servo.eureka-connection-cleaner-time.max": 0.0,
109     "counter.servo.eureka-connection-cleaner-failure": 0,
110     "httpsessions.max": -1,
111     "httpsessions.active": 0
112 }

如果只关心某部分参数可以使用:http://IP:port/metrics/mem来查看特定参数的值

{"mem":373311}

 

posted @ 2018-01-29 16:46  自行车上的程序员  阅读(1387)  评论(0编辑  收藏  举报