Safety combat Spring cloud micro-services -7-7 custom metrics monitoring indicators (2)

Gauge is used to display a number of word


checked, the program dashboard where

the maximum set instrument panel, minimum


save


directly saved

successfully saved prompt

return

this is what we do a simple dashboard

that are not suitable for our counter, because there is no maximum limit.
You can drag the resize.

line chart

Traffic over time curve fluctuations. We start this test class, one second at a frequency of 10 times to visit our orders interface.

Your test class ran in the back, and then we add a panel





to select the data source


rate is a function of the most used, do the calculation on the data collected. rate is to calculate the amount of data per second in the specified range.


According to me this is the code, I want to send a second request 10 times.

Creating an order request, the number of requests per second

inside the square brackets to calculate how long the writing. Made a average. Because time is 10 seconds catch data.

Save this graphic.

summary

百分比的数据分布统计图。

监控某一个服务的服务响应时间。
我的请求99%的请求都在指定的时间内有响应,就表示我的服务是健康的,剩下1%的请求有问题。我认为是正常的。。
监控99%的请求的响应时间,然后到达 一个预值后,给我发报警。这就可以用Summary来实现。

首先要声明一个Summary

summary是一个数据分布统计图。要告诉它你想统计的数据分布的分类数是多少。你要定义一堆指标。说着说是百分比。
给我统计出一个50%的分位数。这个值我允许有5%的误差。这是两个参数的意义。

90%的分位数,允许有1%的的误差。

加入我有10 个请求,响应时间分别是10毫秒、20、30、40......100毫秒.
50%的请求可以在50毫秒内返回。
0.9的分位数,应该是在啊90毫秒。90%的请求是可以在90毫秒内返回的。

他就是统计50%的请求在多少毫秒内返回。
90%的请求可以在多少毫秒内返回。

用这个Summary来统计请求的响应时间

注入requestLatency,覆盖preHandler请求之前的方法,要在请求之前记录下时间,请求之后再记录下时间。这样就知道请求花了多长时间了。


记录了请求之前的时间





修改orderController的方法 ,休眠时间设置成一个随机数。先添加一个lang3的包

请求 休眠子啊100到1000毫秒之间


启动orderAPI


测试类也启动起来。测试类这里的休眠就不sleep了。因为controller里面的方法已经sleep了。

查看拿到的数据。


count:当前指标一共收到了多少请求。38次请求。

sum:38次请求一共花了20秒。50

50%的请求都在509毫秒响应了。90%的请求在921毫秒内响应。

grafana内增加仪表展示

在grafana里面加个面板展示出来这些数据就可以了。





90%的请求的响应时间是927毫秒。



结束

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/12010325.html