Prometheus + Grafana 监控 Spring Cloud 应用

应用依赖

1
2
3
4
5
6
7
8
9
<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>

应用配置

1
2
3
4
5
6
7
8
9
10
11
12
13
#metrics
management:
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
exposure:
include: health, info, httptrace, metrics, threaddump, mappings, prometheus
endpoint:
health:
show-details: always

Prometheus配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
- 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

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :