Spring Boot 自定义指标

Spring Boot 自定义指标

阅读本文需要对一些前置技术有所了解,下面列出的一些前置技术是必须要了解的。

  • Prometheus:这是一个时序数据库,我们的指标数据一般保存在这个数据库中。
  • Grafana:借助Grafana可以将Prometheus中的数据以图表的方式展示出来。
  • Micrometer:是一个用于度量应用程序性能和监控的度量库
  • spring-boot-starter-actuator:用于在 Spring Boot 应用程序中添加运行时管理和监控功能

在项目中如果希望自定义一些指标用于监控系统的运行情况,那么可以通过本文中介绍的方法来实现自定义监控指标,我们先从一个简单的例子来介绍如何实现自定义监控指标。

依赖

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-core</artifactId>
        <version>1.11.4</version>
    </dependency>
    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
        <version>1.11.4</version>
    </dependency>
</dependencies>

实现

这里实现一个健康检查的指标收集器,如果健康检查正常返回1,如果健康检查异常返回 0

相关推荐

  1. SpringBoot--定义starter

    2024-02-03 16:10:01       50 阅读
  2. springboot定义starter

    2024-02-03 16:10:01       44 阅读
  3. SpringBoot定义Starter

    2024-02-03 16:10:01       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-03 16:10:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-03 16:10:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-03 16:10:01       87 阅读
  4. Python语言-面向对象

    2024-02-03 16:10:01       96 阅读

热门阅读

  1. 深度学习的进展

    2024-02-03 16:10:01       46 阅读
  2. 为什么选择AGPL3.0开源协议

    2024-02-03 16:10:01       47 阅读
  3. STL - list

    2024-02-03 16:10:01       51 阅读
  4. 通信设备的发展史

    2024-02-03 16:10:01       44 阅读
  5. 【PostgreSQL灵活使用psql执行SQL的一些方式】

    2024-02-03 16:10:01       60 阅读