actuator官方的介绍

Spring Boot includes a number of additional features to help you monitor and manage your application when it’s pushed to production. You can choose to manage and monitor your application using HTTP endpoints, with JMX or even by remote shell (SSH or Telnet). Auditing, health and metrics gathering can be automatically applied to your application.

actuator是一个强大功能,有助于对应用程序进行监视和管理,通过restful api请求来监管、审计、收集应用的运行情况

1.添加依赖

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-actuator</artifactId>
  4. </dependency>

2.启动项目

用浏览器打开 http://localhost:8080/actuator

  1. {
  2. "_links": {
  3. "self": {
  4. "href": "http://localhost:8080/actuator",
  5. "templated": false
  6. },
  7. "health": {
  8. "href": "http://localhost:8080/actuator/health",
  9. "templated": false
  10. },
  11. "health-component": {
  12. "href": "http://localhost:8080/actuator/health/{component}",
  13. "templated": true
  14. },
  15. "health-component-instance": {
  16. "href": "http://localhost:8080/actuator/health/{component}/{instance}",
  17. "templated": true
  18. },
  19. "info": {
  20. "href": "http://localhost:8080/actuator/info",
  21. "templated": false
  22. }
  23. }
  24. }

actuator暴露了三个简单的endpoint

开启所有接口,在application.properties中,添加

  1. management.endpoints.web.exposure.include=*

刷新 http://localhost:8080/actuator页面,会出现很多endpoint

  1. {
  2. "_links": {
  3. "self": {
  4. "href": "http://localhost:8080/actuator",
  5. "templated": false
  6. },
  7. "auditevents": {
  8. "href": "http://localhost:8080/actuator/auditevents",
  9. "templated": false
  10. },
  11. "beans": {
  12. "href": "http://localhost:8080/actuator/beans",
  13. "templated": false
  14. },
  15. "caches-cache": {
  16. "href": "http://localhost:8080/actuator/caches/{cache}",
  17. "templated": true
  18. },
  19. "caches": {
  20. "href": "http://localhost:8080/actuator/caches",
  21. "templated": false
  22. },
  23. "health-component": {
  24. "href": "http://localhost:8080/actuator/health/{component}",
  25. "templated": true
  26. },
  27. "health-component-instance": {
  28. "href": "http://localhost:8080/actuator/health/{component}/{instance}",
  29. "templated": true
  30. },
  31. "health": {
  32. "href": "http://localhost:8080/actuator/health",
  33. "templated": false
  34. },
  35. ……
  36. }
  37. }

(1)/actuator/health 查看应用健康指标

  1. {
  2. "status": "UP"
  3. }

(2)/actuator/info查看应用的定制信息

  在配置文件中以 info 开头的配置信息

application.properties包含

  1. info.app.name=abc
    info.app.version=1.0.0

返回结果

  1. {
  2. "app": {
  3. "name": "abc",
  4. "version": "1.0.0"
  5. }
  6. }

(3)/actuator/metrics 查看应用基本指标

  返回actuator提供的所有metric的name

  /actuator/metrics/{name}查看具体指标

  使用 /actuator/metrics/jvm.memory.max,查看JVM最大内存

  1. {
  2. "name": "jvm.memory.max",
  3. "description": "The maximum amount of memory in bytes that can be used for memory management",
  4. "baseUnit": "bytes",
  5. "measurements": [
  6. {
  7. "statistic": "VALUE",
  8. "value": 5.583142911E9
  9. }
  10. ],
  11. "availableTags": [
  12. {
  13. "tag": "area",
  14. "values": [
  15. "heap",
  16. "nonheap"
  17. ]
  18. },
  19. {
  20. "tag": "id",
  21. "values": [
  22. "Compressed Class Space",
  23. "PS Survivor Space",
  24. "PS Old Gen",
  25. "Metaspace",
  26. "PS Eden Space",
  27. "Code Cache"
  28. ]
  29. }
  30. ]
  31. }

(4)/actuator/beans 应用中所有Spring Beans的完整列表

  1. "contexts": {
  2. "application": {
  3. "beans": {
  4. "spring.jpa-org.springframework.boot.autoconfigure.orm.jpa.JpaProperties": {
  5. "aliases": [],
  6. "scope": "singleton",
  7. "type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties",
  8. "resource": null,
  9. "dependencies": []
  10. },"uploadController": {
  11. "aliases": [],
  12. "scope": "singleton",
  13. "type": "com.example.demo.controller.UploadController$$EnhancerBySpringCGLIB$$b6fa2feb",
  14. "resource": "file [E:\\java\\demo\\target\\classes\\com\\example\\demo\\controller\\UploadController.class]",
  15. "dependencies": []
  16. },
  17. ……
  18. },
  19. "parentId": null
  20. }
  21. }
  22. }

(5)/actuator/heapdump  dump 一份应用的 JVM 堆信息

  可以使用 JDK 自带的 Jvm 监控工具 VisualVM 打开该文件查看内存快照

(6)/actuator/scheduledtasks  应用中的定时任务信息

(7)/actuator/env 获取全部环境属性

  /actuator/env/{name} 获取特定的环境属性值

  /actuator/env/java.version  java版本

  1. {
  2. "property": {
  3. "source": "systemProperties",
  4. "value": "1.8.0_151"
  5. },
  6. "activeProfiles": [
  7. "dev"
  8. ],
  9. "propertySources": [
  10. {
  11. "name": "server.ports"
  12. },
  13. {
  14. "name": "servletConfigInitParams"
  15. },
  16. {
  17. "name": "servletContextInitParams"
  18. },
  19. {
  20. "name": "systemProperties",
  21. "property": {
  22. "value": "1.8.0_151"
  23. }
  24. },
  25. {
  26. "name": "systemEnvironment"
  27. },
  28. {
  29. "name": "random"
  30. },
  31. {
  32. "name": "applicationConfig: [classpath:/application.properties]"
  33. },
  34. {
  35. "name": "Management Server"
  36. }
  37. ]
  38. }

还有很多,可以去 https://docs.spring.io/spring-boot/docs/2.0.2.RELEASE/actuator-api/html/ 查看

spring boot的actuator的更多相关文章

  1. Spring Boot整合actuator实现监控管理

    Spring Boot使用actuator监控管理 1.在pom文件中导入相关的依赖 <dependency> <groupId>org.springframework.boo ...

  2. 从Unauthorized 401错误学习Spring Boot的Actuator

    之前用Spring Boot都是别人搭好的框架,然后自己在里面写就行了.对原理.细节上都怎么涉及,毕竟需求都做不完.但是昨天一个访问RESTful接口的401问题搞了我2个小时.网上找的很多用: ma ...

  3. Spring Boot (28) actuator与spring-boot-admin

    在上一篇中,通过restful api的方式查看信息过于繁琐,也不直观,效率低下.当服务过多的时候看起来就过于麻烦,每个服务都需要调用不同的接口来查看监控信息. SBA SBA全称spring boo ...

  4. Spring Boot (27) actuator服务监控与管理

    actuaotr是spring boot项目中非常强大的一个功能,有助于对应用程序进行监控和管理,通过restful api请求来监管.审计.收集应用的运行情况,针对微服务而言它是必不可少的一个环节. ...

  5. spring boot之actuator简介

    当我们的开发工作进入尾声,部署上线之后,对于一个程序而言,可能才刚刚开始,对程序的运行情况的监控要伴随着整个生命周期. 如果这个工作由程序员自己来开发,也未尝不可,但本着不重复制造轮子的思想,我们尽量 ...

  6. Spring Boot之Actuator的端点

    Spring Boot Actuator的关键特性是在应用程序里提供众多Web端点,通过它们了解应用程序 运行时的内部状况.有了Actuator,你可以知道Bean在Spring应用程序上下文里是如何 ...

  7. Spring Boot|监控-Actuator

    Spring Boot 为我们提供了一个生产级特性-Actuator,包含很多实际有用的API,下面我们就一起来看看这些API. 一.Actuator 首先在程序中引入Actuator <!-- ...

  8. 第11章 Spring Boot使用Actuator

    在生产环境中,需要实时或定期监控服务的可用性,spring-Boot的Actuator 功能提供了很多监控所需的接口. Actuator是Spring Boot提供的对应用系统的自省和监控的集成功能, ...

  9. spring boot监控--actuator

    原文地址:http://blog.csdn.net/wh_ouyangshuang/article/details/48048111 spring-boot-actuator模块提供了一个监控和管理生 ...

随机推荐

  1. Redis Cluster数据分片机制

    复制粘贴自: https://www.e-learn.cn/content/redis/2344485, 点击链接访问原文 仅供个人学习参考之用, 如有侵权, 请联系删除! 高级开发不得不懂的Redi ...

  2. 51nod1681 公共祖先

    [传送门] 很明显,可以转化成求每个点在两棵树中对应的子树中有多少个相同的节点,对答案的贡献就是$C(x, 2)$.关键就是怎么求这个东西.一是,对第一棵树求出dfs序,然后dfs第二棵树,用树状数组 ...

  3. PHP - register globals

    It seems that the developper often leaves backup files around... 似乎开发人员经常把备份文件放在… 直接下载网站备份: index.ph ...

  4. (知识点1)#pragma once 与 #ifndef 解析

    例如 为了避免同一个文件被include多次,C/C++中有两种方式,一种是#ifndef方式,一种是#pragma once方式.在能够支持这两种方式的编译器上,二者并没有太大的区别,但是两者仍然还 ...

  5. rhce备战笔记

    1)配置selinuxvim /etc/slinux/config    SELINUX=enforcingsetenforce 1getenforce两台都做 2)配置SSHvim /etc/ssh ...

  6. Sublime Text 3安装Package Control并安装Processing插件

    由于PDE编辑界面对中文的支撑太差,于是想换到ST3来编辑代码,结果导致了噩梦的开始. 首先,找不到“Package Control”!!! 这还怎么玩~ 于是打开http://packagecont ...

  7. Harbor高可用

    项目需求: 实现Harbor的HTTPS高可用,由于Harbor 服务器配置不高,直接做HTTPS对上传下载镜像时,若docker客户端多时,会非常慢,为了提高harbor的效率,采用以下方式来解决. ...

  8. 第09组 Alpha冲刺(1/6)

    队名:观光队 组长博客 作业博客 组员实践情况 王耀鑫 过去两天完成了哪些任务 文字/口头描述 完成服务器连接数据库部分代码 展示GitHub当日代码/文档签入记录 接下来的计划 与服务器连接,配合前 ...

  9. 【技术博客】 关于laravel5.1中文件上传测试的若干尝试

    关于laravel5.1中文件上传测试的若干尝试 作者:ZGJ 版本:v1.0 PM注:本人这两天也正在尝试解决这一问题,如有进展将及时更新这一博客 在我们的软工第二阶段中,我开始着手进行后端控制器的 ...

  10. nginx负载均衡的5种策略及原理

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qq_35119422/article/de ...