Skip to content

Metrics

李豪 edited this page Jul 23, 2018 · 13 revisions

Sentinel provides real time metrics, including resource count, response time, concurrency, etc. Usually we can view these metrics on Sentinel-Dashboard, but if you are interesting in the metrics api, here is the detail.

Metrics for resources

1.After application starts up,we can run following command to fetch resources lists in JSON format.

curl http://localhost:8719/clusterNode

[
 {"avgRt":0.0, //avg response time per second
 "blockRequest":0, //block count per minute
 "blockedQps":0.0, //block count per second
 "curThreadNum":0, //current concurrency
 "passQps":1.0, // success exit count per second
 "passReqQps":1.0, //pass count per second
 "resourceName":"/registry/machine", resource name
 "timeStamp":1529905824134, //time stamp
 "totalQps":1.0, // total request count per minute
 "totalRequest":193}, 
  ....
]

2.Display resource information by resource name run command curl http://localhost:8719/cnode?id=xxxx to query a specified resource name,parameter id for resource name,support fuzzy query。

$curl http://11.138.222.145:8719/cnode?id=machine

idx id                                thread    pass      blocked   success    total    aRt   1m-pass   1m-block   1m-all   exeption   
6   /app/aliswitch2/machines.json     0         0         0         0          0        0     0         0          0        0          
7   /app/sentinel-admin/machines.json 0         1         0         1          1        6     0         0          0        0          
8   /identity/machine.json            0         0         0         0          0        0     0         0          0        0          
9   /registry/machine                 0         2         0         2          2        1     192       0          192      0          
10  /app/views/machine.html           0         1         0         1          1        2     0         0          0        0   

3.Following command will return resource's origin info curl http://localhost:8719/origin?id=xxxx

id: nodeA
idx origin  threadNum passedQps blockedQps totalQps aRt   1m-passed 1m-blocked 1m-total 
1   caller1 0         0         0          0        0     0         0          0        
2   caller2 0         0         0          0        0     0         0          0      

origin is defined by calling

Context.enter(resourceNameorigin) 

Resource Path

Any resource which entry node has called following code explicitly, it will be counted as a node in the tree:

Context.enter(resourceNameorigin) 

Running command curl http://localhost:8719/tree to display the calling path in a tree form:

EntranceNode: machine-root(t:0 pq:1 bq:0 tq:1 rt:0 prq:1 1mp:0 1mb:0 1mt:0)
-EntranceNode1: Entrance1(t:0 pq:1 bq:0 tq:1 rt:0 prq:1 1mp:0 1mb:0 1mt:0)
--nodeA(t:0 pq:1 bq:0 tq:1 rt:0 prq:1 1mp:0 1mb:0 1mt:0)
-EntranceNode2: Entrance1(t:0 pq:1 bq:0 tq:1 rt:0 prq:1 1mp:0 1mb:0 1mt:0)
--nodeA(t:0 pq:1 bq:0 tq:1 rt:0 prq:1 1mp:0 1mb:0 1mt:0)

t:threadNum  pq:passQps  bq:blockedQps  tq:totalQps  rt:averageRt  prq: passRequestQps 1mp:1m-passed 1mb:1m-blocked 1mt:1m-total

History Resource Metrics

1.Resources metrics log

Resource metrics log is generated in the directory: ${home}\logs\csp\${appName}-${pid}-metrics.log.${date}.xx. For example, log file name would be: app-3518-metrics.log.2018-06-22.1

1529573107000|2018-06-21 17:25:07|sayHello(java.lang.String,long)|10|3601|10|0|2
index example description
1 1529573107000 time stamp
2 2018-06-21 17:25:07 date
3 sayHello(java.lang.String,long) resource name
4 10 the count of incoming resource per second
5 3601 the block count of the resource per second
6 10 the success exit count of the resource per second
7 0 the exception count per second
8 2 the avg response time

2.block log

Also, the block log would be generated in the dir ${home}\logs\csp\sentinel-block.log. If no block happens, the log will not be generated.

2014-06-20 16:35:10|1|sayHello(java.lang.String,long),FlowException,default,origin|61,0
2014-06-20 16:35:11|1|sayHello(java.lang.String,long),FlowException,default,origin|1,0
index example description
1 2014-06-20 16:35:10 timestamp
2 1 the resource index
3 `sayHello(java.lang.String,long) resource name
4 XXXException FlowException is blocked by flow rules, DegradeException is blocked by degrade rules,SystemExceptionis blocked by system rules
5 default the limit app defined in effective rule
6 origin the origin of the blocked resource. could be empty
7 61,0 61 the blocked count this second. and 0 can be ignored

3.Real time query

curl http://localhost:8719/metric?startTime=XXXX&endTime=XXXX

History Resource Metrics

1529998904000|2018-06-26 15:41:44|abc|100|0|0|0|0
1529998905000|2018-06-26 15:41:45|abc|4|5579|104|0|728
1529998906000|2018-06-26 15:41:46|abc|0|15698|0|0|0
1529998907000|2018-06-26 15:41:47|abc|0|19262|0|0|0
1529998908000|2018-06-26 15:41:48|abc|0|19502|0|0|0
1529998909000|2018-06-26 15:41:49|abc|0|18386|0|0|0
1529998910000|2018-06-26 15:41:50|abc|0|19189|0|0|0
1529998911000|2018-06-26 15:41:51|abc|0|16543|0|0|0
1529998912000|2018-06-26 15:41:52|abc|0|18471|0|0|0
1529998913000|2018-06-26 15:41:53|abc|0|19405|0|0|0
Clone this wiki locally