Commit 1cbb427 1 parent 4428930 commit 1cbb427 Copy full SHA for 1cbb427
File tree 1 file changed +53
-0
lines changed
极客时间-微服务实战160讲/监控模块-Prometheus
1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments