springboot项目监控prometheu+grafana

目录

一、springboot项目配置

二、springboot项目接入prometheu

三、配置Grafana


一、springboot项目配置

pom.xml

    <dependency>

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

         <artifactId>spring-boot-starter-actuator</artifactId><!-- 版本随工程自适应 -->

      </dependency>

      <dependency>

         <groupId>io.micrometer</groupId>

         <artifactId>micrometer-core</artifactId>

         <version>1.6.2</version>

      </dependency>

      <dependency>

         <groupId>io.micrometer</groupId>

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

         <version>1.6.2</version>

      </dependency>

application.properties

management.endpoints.web.exposure.include=*

management.endpoint.health.show-details=always

management.endpoint.prometheus.enabled=true

配置好后启动springboot项目访问 http://localhost:8086/actuator/prometheus 看到以下页面即说明配置成功

 http://localhost:8086/actuator看到所有的

 如果项目有登录拦截,在项目中将路径 /actuator/* 设置免登陆可访问

 

二、springboot项目接入prometheu

在服务器上已经安装了docker的前提

增加监控进程修改配置

vim /etc/prometheus/prometheus.yml

新增一条类似如下的记录

global:
  scrape_interval:     60s
  evaluation_interval: 60s


scrape_configs:
  - job_name: prometheus
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['springboot项目ip:端口']

启动prometheus

docker run -p 9090:9090 --name=-prometheus -v  /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus &

如果已经有同名进程启动,需要杀死进程执行

 docker rm prometheus

访问http://localhost:9090/  ,看见如下界面说明启动成功

 

三、配置Grafana

1、从官网下载,安装https://grafana.com/grafana/download

2、启动,访问:http://localhost:3000/  默认账户密码 admin/admin

3、配置数据源

4、新增看板

http://localhost:8086/actuator/prometheus 查看参数(就是你要监控的那个springboot项目)

 

 

配置完后保存即可

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值