Prometheus + Grafana監(jiān)控springboot應(yīng)用
本示例適用于無(wú)注冊(cè)中心的簡(jiǎn)單場(chǎng)景
應(yīng)用程序配置
-
引入依賴
gradleimplementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'io.micrometer:micrometer-registry-prometheus'
maven
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency>
-
修改配置
management: endpoint: prometheus: enabled: true metrics: export: prometheus: enabled: true tags: application: ${spring.application.name} endpoints: jmx: exposure: exclude: "*" web: exposure: include: "*"
Prometheus
prometheus.yml
添加job初肉,指向每個(gè)應(yīng)用節(jié)點(diǎn)的http地址:scrape_configs: - job_name: 'application_exporter' metrics_path: /actuator/prometheus static_configs: - targets: - 192.168.3.220:8084 - 192.168.1.10:8084
Grafana
導(dǎo)入dashboard模板
system-monitor_rev2.json-
查看效果