SpringBoot之actuator

Easter79
• 阅读 476

在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}
点赞
收藏
评论区
推荐文章
Easter79 Easter79
2年前
springcloud的配置文件的读取顺序
SpringBoot默认支持properties和YAML两种格式的配置文件。前者格式简单,但是只支持键值对。如果需要表达列表,最好使用YAML格式。SpringBoot支持自动加载约定名称的配置文件,例如application.yml。如果是自定义名称的配置文件,就要另找方法了。可惜的是,不像前者有@PropertySource这样方便的加载方式,
Easter79 Easter79
2年前
springboot2的redis缓存管理器cacheManager配置,使存入json格式数据
springboot中默认存入缓存的数据,使用的序列化方案对应的值不方便查看,我们希望存入json格式值,所以要配置cacheManager达到效果springboot2的缓存管理器配置和springboot1有所差别,所以记录下来:效果图:!(https://oscimg.oschina.net/oscnet/1ccf3c57249b0dd
Stella981 Stella981
2年前
Spring 学习笔记(三):Spring Bean
1Bean配置Spring可以看做是一个管理Bean的工厂,开发者需要将Bean配置在XML或者Properties配置文件中。实际开发中常使用XML的格式,其中<bean中的属性或子元素如下:id:Bean在BeanFactory中的唯一标识,在代码中通过BeanFac
Stella981 Stella981
2年前
Spring Boot Actuator监控
1、简介  springboot有四大杀器:starters、autoConfiguration、cli、actuator。actuator是springboot对应用的监控组件,可以查看应用系统的配置、资源使用等统计功能。2、actuator主要功能HTTP方法路径描述鉴权默认可以用备注GET/autoconfi
Stella981 Stella981
2年前
Linux下查看网络状态的方法
  当我的设备在机房,懒得去查看网线连接情况;或者设备在远端,没有条件让眼睛亲临现场,我需要在终端查看设备网络接口的物理连接状态。基于此种场景,我就了解了几种关于命令查看网络状态的方法。  1\.ifconfig  ifconfig是Linux系统自带命令,可以查看接口配置IP的情况、临时配置接口IP(永久配置可以使用yast或者修改/et
Stella981 Stella981
2年前
Django学习之模型层
模型层查看orm内部sql语句的方法的方法1.如果是queryset对象,那么可以点query直接查看该queryset的内部sql语句2.在Django项目的配置文件中,配置一下参数即可实现所有的orm在查询的时候自动打印对应的sql语句LOGGING{'version':1,
Stella981 Stella981
2年前
SpringBoot之actuator
在springBoot中集成actuator可以很方便的管理和监控应用的状态。暴露的Restful接口有:HTTP方法路径描述鉴权GET/autoconfig查看自动配置的使用情况trueGET/configprops查看配置属性,包括默认配置trueGET/beans查看bean及其关系列表
Stella981 Stella981
2年前
SpringBoot2.0 基础案例(16):配置Actuator组件,实现系统监控
本文源码GitHub地址:知了一笑https://github.com/cicadasmile/springbootbase一、Actuator简介1、监控组件作用在生产环境中,需要实时或定期监控服务的可用性。SpringBoot的actuator(健康监控)
Easter79 Easter79
2年前
SpringBoot2.0 基础案例(16):配置Actuator组件,实现系统监控
本文源码GitHub地址:知了一笑https://github.com/cicadasmile/springbootbase一、Actuator简介1、监控组件作用在生产环境中,需要实时或定期监控服务的可用性。SpringBoot的actuator(健康监控)
金旋 金旋
3个月前
火哥内核6期
//下仔のke:https://yeziit.cn/14009/SpringBoot的核心包括四个部分:自动配置、起步依赖、命令行界面和Actuator。自动配置:SpringBoot能根据类路径下的内容自动配置一些公共大型应用,提供@EnableAuto
Easter79
Easter79
Lv1
今生可爱与温柔,每一样都不能少。
文章
2.8k
粉丝
5
获赞
1.2k