spring boot 2.x 应用可视化监控

来源:简书

内容:应用可视化监控(prometheus && grafana)

https://www.jianshu.com/p/7ecb57a3f326


修改为spring boot 2.0时

1、首先,添加依赖如下依赖:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micromether-registry-prometheus</artifactId>
        </dependency>
2、 然后启动类的注解不要了。

3、配置application.properties

management.endpoints.web.exposure.include=*

访问地址:

http://localhost:8080/xxxx/actuator/prometheus

4 、然后,编写配置文件 prometheus.yml

global:
  scrape_interval: 15s
  scrape_timeout: 10s
  evaluation_interval: 15s
alerting:
  alertmanagers:
  - static_configs:
    - targets: []
    scheme: http
    timeout: 10s
scrape_configs:
- job_name: prometheus
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /TestData/actuator/prometheus  #此处填写 上面一步的访问地址
  scheme: http
  static_configs:
  - targets:
    - localhost:8080  #此处填写 Spring Boot 应用的 IP + 端口号

5、接着,启动 Prometheus :(此处配置原文中有问题,最后俩是双横线)

$ docker run -d \
--name prometheus \
-p 9090:9090 \
-m 500M \
-v "$(pwd)/prometheus.yml":/prometheus.yml \
-v "$(pwd)/data":/data \
prom/prometheus \
--config.file=/prometheus.yml \
--log.level=info

6、grafana配置的时候要用ip好像,用localhost好像不生效。(问题不大)


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值