zoukankan      html  css  js  c++  java
  • (029)Spring Boot之监测与度量

      springboot提供了监测与度量的功能,记录如下:

      application.properties

    management.server.port=9001  #指定监控的端口,默认与web端口一致
    management.endpoints.web.base-path=/monitor  #指定监控的路径,默认是:/actuator
    management.endpoints.web.exposure.include=*  #指定监控范围,*代表监控所有项,默认只监控:health、info
    management.endpoint.health.show-details=always  #显示健康具体信息,默认不会显示详细信息  

      引入starter-actuator依赖

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

      完整pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.edu.spring</groupId>
        <artifactId>springboot_web</artifactId>
        <version>1.0.0</version>
    
        <name>springboot_web</name>
        <!-- FIXME change it to the project's website -->
        <url>http://www.example.com</url>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.4.RELEASE</version>
        </parent>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
        </dependencies>
    
    </project>
    View Code

      启动工程,如下:

       从图中可以看出监测14项,端口是9001。下面简单举例:

      http://localhost:9001/monitor/beans  监测所有的bean,如下:

       http://localhost:9001/monitor/health  监测,磁盘、数据库连接等信息,如下:

       http://localhost:9001/monitor/env  监测环境信息,包含application.properties里面的属性、值

      http://localhost:9001/monitor/loggers   监测日志信息

      http://localhost:9001/monitor/mappings   监测url

      http://localhost:9001/monitor/info   监测application.properties中info开头的信息,如下:

    info.aa=aa
    info.bb=bb

     

  • 相关阅读:
    STM32f469I discovery烧写demo例程
    dsp5509的中断系统
    DSP5509之采样定理
    DSP5509开发之FPGA接口
    mongodb学习之:安全和认证
    mongodb学习之:GridFS
    tornado之异步web服务一
    mongodb学习之:数据库命令以及固定集合
    docker: Dockerfile命令介绍
    mongodb学习之:聚合
  • 原文地址:https://www.cnblogs.com/javasl/p/11966675.html
Copyright © 2011-2022 走看看