|
Background: There is a referral service online, larger than the log, under qps want to make sure is not too high
Question: qps how to view the log based on a service
tail -f XXX.log, the log can be found in the following format:
[8708-10 14:51:44 638 INFO] [async task worker [61]] recommend.components.KeywordService [87] - cateid = 252 pageNum = 1
[8708-10 14:51:44 666 INFO] [async task worker [62]] recommend.components.KeywordService [87] - cateid = 42205
[8708-10 14:51:44 673 INFO] [async task worker [0]] recommend.components.KeywordService [87] - cateid = 29 pageNum = 2
[8708-10 14:51:44 677 INFO] [async task worker [1]] recommend.components.KeywordService [87] - cateid = 252 pageNum = 3
Log specification, there is a "request time", through the "request time" estimated qps services, follow these steps:
(1) make a request to have a go first and only line of logs, commonly used tools are grep, this case needs to grep recommend.components.KeywordService, the results obtained, a request corresponding to the line of the log
(2) Remove the time this column, commonly used tool is cut or awk, here is what you cut (linux everyone to look up man)
-d parameter, separated by a certain character
-f parameter, the first of several columns separated after removal
In this example, after following the "space" to separate the time in the second column
1,2-step operation performed, the results obtained for the
14:51:44
14:51:44
14:51:45
14:51:45
14:51:46
14:51:46
(3) the results go heavy, take count, commonly used tools are uniq, parameter -c
Therefore, the entire shell command is:
Command: tail -f XXX.log | grep recommend.components.KeywordService | cut -d '' -f2 | cut -d ':' -f3 | uniq -c
Description: Take an incremental | request fetches a row | time to intercept it | out to intercept the seconds | to re-take the count
The result is
13643
12644
11545
13146
13247
You can see 14: 51: 43, a total of 136 log
44, there are 126 log
45, there are 115 log
...
qps conclusion of this module, the single is about 120-130 |
|
|
|