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

来源:简书

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

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


修改为spring boot 2.0时

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

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-actuatorartifactId>
        dependency>

        <dependency>
            <groupId>io.micrometergroupId>
            <artifactId>micromether-registry-prometheusartifactId>
        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好像不生效。(问题不大)


你可能感兴趣的:(spring,boot,收集)