Skip to content

Commit 1cbb427

Browse files
committed
add prometheus
1 parent 4428930 commit 1cbb427

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Java应用埋点和监控实验
2+
======
3+
4+
### 实验步骤
5+
6+
#### 1. Review和运行埋点样例代码
7+
8+
*[instrumentation-example](https://github.com/spring2go/prom_lab/tree/master/lab04)导入Eclipse IDE
9+
* Review代码理解模拟任务系统原理和埋点方式
10+
* 以Spring Boot方式运行埋点案例
11+
* 通过`http://localhost:8080/prometheus`查看metrics
12+
13+
#### 2. 配置和运行Promethus
14+
15+
添加针对`instrumentation-example`的监控job
16+
17+
```
18+
- job_name: 'instrumentation-example'
19+
metrics_path: /prometheus
20+
static_configs:
21+
- targets: ['localhost:8080']
22+
```
23+
24+
运行Prometheus
25+
26+
```
27+
./prometheus.exe
28+
```
29+
30+
通过`Prometheus->Status``configuration``targets`校验配置正确
31+
32+
#### 3. 生成测试数据和查询Metrics
33+
34+
查询`instrumentation-example`在UP**1**状态
35+
```
36+
up{job="instrumentation-example"}
37+
```
38+
39+
运行[queueUpJobs.sh](queueUpJobs.sh)产生100个job
40+
```
41+
./queueUpJobs.sh
42+
```
43+
44+
查询JobQueueSize变化曲线(调整时间范围到5m):
45+
```
46+
job_queue_size{job="instrumentation-example"}
47+
```
48+
49+
查询90分位Job执行延迟分布:
50+
```
51+
histogram_quantile(0.90, rate(jobs_completion_duration_seconds_bucket{job="instrumentation-example"}[5m]))
52+
```
53+

0 commit comments

Comments
 (0)