springboot+prometheus+grafana

一、springboot

  1、pom   

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
   <groupId>io.micrometer</groupId>
   <artifactId>micrometer-registry-prometheus</artifactId>
   <scope>runtime</scope>
</dependency>

    2、yml

spring:
  application:
    name: PrometheusApp

#Prometheus springboot监控配置
management:
  endpoints:
    web:
      exposure:
        include: '*'
  metrics:
    export:
      prometheus:
        enabled: true
    tags:
      application: ${spring.application.name} # 暴露的数据中添加application label

3、访问

   http://localhost:8080/actuator/prometheus

二、prometheus

1、官网下载安装

prometheus-2.37.8.windows-amd64

2、配置文件

  - job_name: "windows-exporter"
    static_configs:
      - targets: ["localhost:9182"]
    
  - job_name: 'PrometheusApp'
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['localhost:8080']

3、启动访问 

http://localhost:9090/targets?search=

三、exporter

1、下载启动

windows_exporter-0.23.1-amd64.exe

2、访问

http://localhost:9182/

四、grafana

1、下载安装

grafana-10.0.2.windows-amd64.msi

2、运行

grafana-server.exe

3、访问

http://localhost:3000 admin/admin

4、设置datasource 

     url: http://localhost:9090/

 5、Import dashboard ,Dashboards | Grafana Labs

      10467  机器

      12900  springboot

6、自定义业务监控

@Autowired
private MeterRegistry meterRegistry;
Counter.builder("metrics.request.count").tags("apiCode", "order").register(meterRegistry).increment();

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值