应用依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Micrometer Prometheus registry -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
应用配置
#metrics
management:
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
exposure:
include: health, info, httptrace, metrics, threaddump, mappings, prometheus
endpoint:
health:
show-details: always
Prometheus配置
- job_name: 'spring_cloud_application'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['192.168.16.8:8801']
labels:
application: appblog
instance: service-a
group: inner
- targets: ['192.168.16.8:8802']
labels:
application: appblog
instance: service-b
group: inner
- targets: ['192.168.16.8:8803']
labels:
application: appblog
instance: service-c
group: inner
- targets: ['192.168.16.10:8804']
labels:
application: appblog
instance: service-d
group: inner
- targets: ['192.168.16.10:8805']
labels:
application: appblog
instance: service-e
group: inner