springboot配置Prometheus

本文涉及的产品
EMR Serverless StarRocks,5000CU*H 48000GB*H
可观测监控 Prometheus 版,每月50GB免费额度
简介: 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博客  


相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
相关文章
|
2月前
|
Prometheus 监控 Cloud Native
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
|
20天前
|
存储 Prometheus 监控
在Ubuntu系统上安装与配置Prometheus的步骤
通过以上步骤,您应该已经成功在Ubuntu系统上安装并配置了Prometheus。您现在可以开始使用Prometheus收集和分析您的系统和应用程序的指标数据了。
39 1
|
2月前
|
Prometheus 监控 Cloud Native
prometheus学习笔记之Grafana安装与配置
prometheus学习笔记之Grafana安装与配置
|
2月前
|
Prometheus 监控 Cloud Native
Spring Boot 性能护航!Prometheus、Grafana、ELK 组合拳,点燃数字化时代应用稳定之火
【8月更文挑战第29天】在现代软件开发中,保证应用性能与稳定至关重要。Spring Boot 作为流行的 Java 框架,结合 Prometheus、Grafana 和 ELK 可显著提升监控与分析能力。Prometheus 负责收集时间序列数据,Grafana 将数据可视化,而 ELK (Elasticsearch、Logstash、Kibana)则管理并分析应用日志。通过具体实例演示了如何在 Spring Boot 应用中集成这些工具:配置 Prometheus 获取度量信息、Grafana 显示结果及 ELK 分析日志,从而帮助开发者快速定位问题,确保应用稳定高效运行。
48 1
|
2月前
|
存储 Prometheus 监控
Prometheus 的报警机制:Alertmanager 的配置与使用
【8月更文第29天】Prometheus 是一个非常强大的监控系统,它不仅能够收集和存储时间序列数据,还能通过 Alertmanager 提供灵活的报警机制。Alertmanager 负责接收 Prometheus 发送的警报,并根据配置的规则执行相应的通知动作。本文将详细介绍如何配置 Alertmanager 以及如何使用它来实现基于 Prometheus 指标的报警通知。
67 0
|
2月前
|
存储 Prometheus Cloud Native
[prometheus]配置alertmanager和钉钉告警
[prometheus]配置alertmanager和钉钉告警
|
3月前
|
Prometheus 监控 Cloud Native
使用Spring Boot和Prometheus进行监控
使用Spring Boot和Prometheus进行监控
|
4月前
|
Prometheus 监控 Cloud Native
性能监控神器Prometheus、Grafana、ELK 在springboot中的运用
【6月更文挑战第27天】在 Spring Boot 应用中,监控和日志管理是确保系统稳定性和性能的重要手段。
159 4
|
4月前
|
Prometheus 监控 Cloud Native
SpringBoot2.x整合Prometheus+Grafana【附源码】
SpringBoot2.x整合Prometheus+Grafana【附源码】
50 1
|
15天前
|
Prometheus 监控 Cloud Native
介绍如何使用Prometheus进行监控
介绍如何使用Prometheus进行监控
53 3
下一篇
无影云桌面