springboot配置Prometheus

简介: springboot配置Prometheus

1.新增springboot项目

我是用的我上面的那个项目。spring-boot版本2.2.4.RELEASE

2.配置yml文件

management:

 endpoint:

   prometheus:

     enabled: true

   jmx:

     enabled: true

 endpoints:

   web:

     exposure:

       include: '*'

     base-path: /metrics

3.引入对应依赖

<!--添加Prometheus监控-->

<dependency>

   <groupId>org.springframework.boot</groupId>

   <artifactId>spring-boot-starter-actuator</artifactId>

</dependency>

<dependency>

   <groupId>io.micrometer</groupId>

   <artifactId>micrometer-registry-prometheus</artifactId>

</dependency>

4.添加配置文件

 
 
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class CommonConfiguration {
    //prometheus+grafana+springboot2监控集成配置
    //访问 http://ip:port/metrics/prometheus 
    // http://localhost:8088/metrics/prometheus
    @Bean
    public MeterRegistryCustomizer meterRegistryCustomizer(MeterRegistry meterRegistry) {
        return meterRegistry1 -> meterRegistry.config().commonTags("application", "AfcPay");
    }
}

5.启动springboot项目,查看是否成功

访问http://localhost:8088/metrics/prometheus

显示此页面代表配置成功,这些信息都是actuator的一些监控信息。

 

具体安装操作,借鉴这篇文章看下。

Prometheus 安装与配置_一百减一是零啊的博客-CSDN博客  


相关文章
|
Prometheus 监控 Cloud Native
SpringBoot+Prometheus+Grafana 实现自定义监控
SpringBoot+Prometheus+Grafana 实现自定义监控
|
9月前
|
XML JSON Java
SpringBoot入门(三) 之springboot的配置配置文件以及yaml的使用
SpringBoot入门(三) 之springboot的配置配置文件以及yaml的使用
159 0
SpringBoot入门(三) 之springboot的配置配置文件以及yaml的使用
|
18天前
|
存储 Java 数据库
SpringBoot整合InfluxDB
SpringBoot整合InfluxDB
16 0
|
4月前
|
Prometheus 监控 Cloud Native
SpringBoot3 整合Prometheus + Grafana
SpringBoot3 整合Prometheus + Grafana
SpringBoot3 整合Prometheus + Grafana
|
10月前
|
Java
springboot优雅的获取yml配置
springboot优雅的获取yml配置
|
9月前
|
前端开发 数据可视化 JavaScript
SpringBoot与Loki的那些事
因为网上好多都没有通过Loki的API自己实现对日志监控系统,所以我就下定决心自己出一版关于loki与springboot的博文供大家参考,这个可以说是比较实用,很适合中小型企业。因此我酝酿了挺久了,对于loki的研究也比较久,希望各位读者能有新的收获。
143 0
|
11月前
|
Prometheus 监控 Cloud Native
使用Prometheus监控SpringBoot应用
使用Prometheus监控SpringBoot应用
103 0
|
12月前
|
Java
SpringBoot 下配置日志
在 application.properties 配置文件中配置。如果在SpringBoot文件中使用日志功能,建议使用@Log4j2注解。日志级别:RACE < DEBUG < INFO < WARN < ERROR < FATAL
78 0
|
监控
springboot09、监控
springboot09、监控
65 0
springboot09、监控
|
Prometheus 监控 Cloud Native
SpringBoot2.x整合Prometheus+Grafana【附源码】
SpringBoot2.x整合Prometheus+Grafana【附源码】
335 0
SpringBoot2.x整合Prometheus+Grafana【附源码】