首页 > 其他分享 >Prometheus接入(四、Spring Boot接入)

Prometheus接入(四、Spring Boot接入)

时间:2023-11-03 16:45:56浏览次数:23  
标签:接入 Spring Boot application Prometheus registry spring

环境

CentOS 7.9 + Spring Boot 2.6.8

安装

1、依赖引入

        <!-- 预设监控 -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>
        <!--健康监控-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

2、配置文件

management:
  endpoints:
    web:
      base-path: "/status"       ## 自定义暴露地址
      exposure:
        include: "*"
  server:
    port: 12012                  ## 自定义暴露端口
  metrics:
    tags:
      application: ${spring.application.name}
  security:
    enabled: false

4、在Application.java中添加

    /**
     * 应用名称
     */
    @Value("${spring.application.name}")
    private String application;

    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer() {
        return (registry -> registry.config().commonTags("MyApplication", application));
    }

5、启动查看指标

http://localhost:12012/status/prometheus

标签:接入,Spring,Boot,application,Prometheus,registry,spring
From: https://www.cnblogs.com/sefuture/p/17807901.html

相关文章

  • Linux环境Prometheus接入(三、MySQL监控接入mysqld_exporter)
    环境CentOS7.9安装1、命令下载wgethttps://github.com/prometheus/mysqld_exporter/releases/download/v0.15.0/mysqld_exporter-0.15.0.linux-amd64.tar.gztar-zxfmysqld_exporter-0.15.0.linux-amd64.tar.gzmvmysqld_exporter-0.15.0.linux-amd64.tar.gz/home/mysq......
  • Linux环境Prometheus接入(四、系统监控接入node_exporter)
    环境CentOS7.9安装1、命令下载wgethttps://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gztar-zxfnode_exporter-1.6.1.linux-amd64.tar.gzmvnode_exporter-1.6.1.linux-amd64/home/node_exporter2、配置系......
  • Linux环境Prometheus接入(一、Prometheus安装)
    环境CentOS7.9安装1、自行下载https://prometheus.io/download/2、命令下载wgethttps://github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-amd64.tar.gz3、解压tar-zvfprometheus-2.47.2.linux-amd64.tar.gzmvprometheus-2.......
  • Linux环境Prometheus接入(二、Grafana安装)
    环境CentOS7.9安装1、命令下载yuminstall-yhttps://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.0-1.x86_64.rpm2、启动、查看状态systemctlstartgrafana-serversystemctlstatusgrafana-server-l3、修改启动端口cd/etc/grafanavigrafa......
  • Spring @Value注入Date类型变量
    @DateTimeFormat(pattern="yyyy-MM-ddHH:mm:ss")@Value("${dateValue:2023-11-0100:00:00}")privateDatenoWxMomentsEnableDateStr; ......
  • springboot + maven + war
    参考文档:springboot配置https://blog.csdn.net/weixin_42594143/article/details/132651455maven项目打war包https://blog.csdn.net/yuanpeij/article/details/120563593https://blog.51cto.com/u_16099190/63531951、项目启动类在SpringBoot应用中,如果需要将应......
  • SpringBoot自动装配(二)源码分析
    基于SpringBoot2.7.11step1.从EnableAutoConfiguration注解开始注解@EnableAutoConfiguration开启了自动配置然后SpringBoot在启动的时候通过类路径进行扫描查找所有META-INF/spring.factories文件加载其中所有的自动配置类step2.应用启动@SpringBootApplicationpub......
  • prometheus-webhook-dingtalk 报警模板
    moretemplate.tmpl{{define"__subject"}}[{{.Status|toUpper}}{{ifeq.Status"firing"}}:{{.Alerts.Firing|len}}{{end}}]{{end}}{{define"__alert_list"}}{{range.}}---**告警名称**:{{index.Annotations"ti......
  • Spring Boot Bean的多种加载方式
     在SpringBoot中,您可以以多种方式加载Bean,这取决于项目的需求和设计。以下是一些常见的加载Bean的方式以及相应的示例源代码。1.组件扫描(ComponentScanning)组件扫描是SpringBoot中默认的Bean加载方式,它会自动扫描指定包及其子包,寻找带有@Component及其衍生注......
  • 微服务+Spring Cloud的建筑工地智慧管理平台源码
    智慧工地全套源码(PC端,移动端,大屏端)智慧工地系统充分利用计算机技术、互联网、物联网、云计算、大数据等新一代信息技术,以PC端,移动端,设备端三位一体的管控方式为企业现场工程管理提供了先进的技术手段。让劳务、设备、物料、安全、环境、能源、资料、计划、质量、视频监控等十大管理......