springboot项目加入actuator和prometheus依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-prometheus</artifactId></dependency>
springboot暴露服务端口
management: endpoints: web: exposure: include: health,info,env,metrics,prometheus,beans server: port: 9001暴露端口建议在内网环境下,不然会有敏感数据泄露的问题
prometheus配置文件修改,增加新的job
- job_name: admin metrics_path: '/actuator/prometheus' static_configs: - targets: ['172.20.100.52:9001']//端口为actuator暴露的端口 labels: instance: admingrafana增加对springboot项目的panel,配置想要暴露的监控materics
