maven

  1. <!--监控-->
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-actuator</artifactId>
  5. </dependency>
  6. <!--适配prometheus-->
  7. <dependency>
  8. <groupId>io.micrometer</groupId>
  9. <artifactId>micrometer-registry-prometheus</artifactId>
  10. </dependency>
  11. <!-- https://mvnrepository.com/artifact/io.github.mweirauch/micrometer-jvm-extras -->
  12. <dependency>
  13. <groupId>io.github.mweirauch</groupId>
  14. <artifactId>micrometer-jvm-extras</artifactId>
  15. <version>0.2.2</version>
  16. </dependency>

yaml

  1. spring:
  2. application:
  3. name: zlintent
  4. # 监控配置
  5. management:
  6. endpoint:
  7. health:
  8. show-details: always
  9. metrics:
  10. enabled: true
  11. prometheus:
  12. enabled: true
  13. endpoints:
  14. web:
  15. exposure:
  16. include: '*'
  17. metrics:
  18. export:
  19. prometheus:
  20. enabled: true
  21. #访问http://localhost:8080/actuator/info
  22. info:
  23. author: zhangl
  24. mobile: iphone

配置prometheus.yml

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

  - job_name: "springboot-prometheus"
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ["192.168.1.4:8080"]

Grafana安装模板

选用了4701模板的JVM监控和12900SpringBoot监控
image.png
image.png
image.png

JVM信息(4701)

image.png
image.png
image.png
image.png

SpringBoot信息(12900)

image.png

服务器监控(8919)

image.png
【中文版本】2020.10.10更新,增加整体资源展示!支持 Grafana6&7,Node Exporter v0.16及以上的版本,优化重要指标展示。包含整体资源展示与资源明细图表:CPU 内存 磁盘 IO 网络等监控指标。https://github.com/starsliao/Prometheus