1. springboot项目加入actuator和prometheus依赖

      1. <dependency>
      2. <groupId>org.springframework.boot</groupId>
      3. <artifactId>spring-boot-starter-actuator</artifactId>
      4. </dependency>
      5. <dependency>
      6. <groupId>io.micrometer</groupId>
      7. <artifactId>micrometer-registry-prometheus</artifactId>
      8. </dependency>
    2. springboot暴露服务端口

      management:
      endpoints:
       web:
         exposure:
           include: health,info,env,metrics,prometheus,beans
      server:
       port: 9001
      

      暴露端口建议在内网环境下,不然会有敏感数据泄露的问题

    3. prometheus配置文件修改,增加新的job

      - job_name: admin
       metrics_path: '/actuator/prometheus'
       static_configs:
         - targets: ['172.20.100.52:9001']//端口为actuator暴露的端口
           labels:
             instance: admin
      
    4. grafana增加对springboot项目的panel,配置想要暴露的监控materics