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暴露给外网的,我们可以在配置文件禁用鉴权拦截。

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

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

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

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

{"mem":373311}
点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

springcloud的配置文件的读取顺序

SpringBoot默认支持properties和YAML两种格式的配置文件。前者格式简单,但是只支持键值对。如果需要表达列表,最好使用YAML格式。SpringBoot支持自动加载约定名称的配置文件,例如application.yml。如果是自定义名称的配置文件,就要另找方法了。可惜的是,不像前者有@PropertySource这样方便的加载方式,

springboot2的redis缓存管理器cacheManager配置,使存入json格式数据

springboot中默认存入缓存的数据,使用的序列化方案对应的值不方便查看,我们希望存入json格式值,所以要配置cacheManager达到效果springboot2的缓存管理器配置和springboot1有所差别,所以记录下来:效果图:!(https://oscimg.oschina.net/oscnet/1ccf3c57249b0dd

Spring 学习笔记(三):Spring Bean

1Bean配置Spring可以看做是一个管理Bean的工厂,开发者需要将Bean配置在XML或者Properties配置文件中。实际开发中常使用XML的格式,其中<bean中的属性或子元素如下:id:Bean在BeanFactory中的唯一标识,在代码中通过BeanFac

Spring Boot Actuator监控

1、简介  springboot有四大杀器:starters、autoConfiguration、cli、actuator。actuator是springboot对应用的监控组件,可以查看应用系统的配置、资源使用等统计功能。2、actuator主要功能HTTP方法路径描述鉴权默认可以用备注GET/autoconfi

Linux下查看网络状态的方法

  当我的设备在机房,懒得去查看网线连接情况;或者设备在远端,没有条件让眼睛亲临现场,我需要在终端查看设备网络接口的物理连接状态。基于此种场景,我就了解了几种关于命令查看网络状态的方法。  1\.ifconfig  ifconfig是Linux系统自带命令,可以查看接口配置IP的情况、临时配置接口IP(永久配置可以使用yast或者修改/et