zoukankan      html  css  js  c++  java
  • SpringBoot学习笔记(14)----应用监控-HTTP方式

    SpringBoot提供了三种应用监控的方式

      通过HTTP(最简单方便)

      通过JMX

      通过远程shell

    这里就是用最简单的方式来使用SpringBoot的应用监控

    首先引入依赖,pom文件如下

      

     <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
        <!--由于应用监控会暴露很多服务器信息,所以需要引入security对应用进行保护-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
            </dependency>

      配置文件如下

      application.properties

    #actuator端口
    management.server.port=9001
    #修改访问路径  2.0之前默认是/   2.0默认是 /actuator  可以通过这个属性值修改
    management.endpoints.web.base-path=/monitor
    #开放所有页面节点  默认只开启了health、info两个节点
    management.endpoints.web.exposure.include=*
    #显示健康具体信息  默认不会显示详细信息
    management.endpoint.health.show-details=always
    
    #使用security保护端点,因为监控的会有很多敏感的信息,设置之后会需要登陆之后才能进入应用监控
    spring.security.user.name=wangx
    spring.security.user.password=wangx
    spring.security.user.roles=SUPERUSER

      配置之后启动系统,SpringBoot就已经对应用进行了监控,它是通过监控各个端点来实现的。

      访问http://localhost:9001/monitor/可以看到每个监控的所有端点的url,直接访问即可查看该运用的该端点的信息 

      ENDPOINTS
      1.X 的时候属性:  HTTP 方法 路径 描述

      GET /autoconfig 提供了一份自动配置报告,记录哪些自动配置条件通过了,哪些没通过
      GET /configprops 描述配置属性(包含默认值)如何注入Bean
      GET /beans 描述应用程序上下文里全部的Bean,以及它们的关系
      GET /dump 获取线程活动的快照
      GET /env 获取全部环境属性
      GET /env/{name} 根据名称获取特定的环境属性值
      GET /health 报告应用程序的健康指标,这些值由HealthIndicator的实现类提供
      GET /info 获取应用程序的定制信息,这些信息由info打头的属性提供
      GET /mappings 描述全部的URI路径,以及它们和控制器(包含Actuator端点)的映射关系
      GET /metrics 报告各种应用程序度量信息,比如内存用量和HTTP请求计数
      GET /metrics/{name} 报告指定名称的应用程序度量值
      POST /shutdown 关闭应用程序,要求endpoints.shutdown.enabled设置为true
      GET /trace 提供基本的HTTP请求跟踪信息(时间戳、HTTP头等)
      2.0 部分更改:

      1.x 端点 2.0 端点(改变)
      /actuator 不再可用。 但是,在 management.endpoints.web.base-path 的根目录中有一个映射,它提供了到所有暴露端点的链接。
      /auditevents 该after参数不再需要
      /autoconfig 重命名为 /conditions
      /docs 不再可用
      /health 现在有一个 management.endpoint.health.show-details 选项 never, always, when-authenticated,而不是依靠 sensitive 标志来确定 health 端点是否必须显示全部细节。 默认情况下,/actuator/health公开并且不显示细节。
      /trace 重命名为 /httptrace

  • 相关阅读:
    open_basedir restriction in effect的错误及其解决办法
    SNMP-网络管理协议
    安装cacti监控系统
    并发时-修改Linux系统下的最大文件描述符限制
    js new date()说明
    阿里云ECS环境部署 centos 6.5
    sysbench
    http_load
    LeetCode: Spiral Matrix
    LeetCode:Length of Last Word
  • 原文地址:https://www.cnblogs.com/Eternally-dream/p/9817120.html
Copyright © 2011-2022 走看看