alpの使い方(基本編)
文字数制限に引っかかったので記事を分割しました。発展編はこちら。
主にISUCONで使われているアクセスログ集計ツール alp の使い方を、ISUCON10オンライン予選問題のアクセスログを例に紹介します。
執筆時現在の最新バージョンはv1.0.11です。
インストール方法
https://github.com/tkuchiki/alp/releases 上のバイナリをダウンロードして利用することができます。
また、以下の方法でインストールすることもできます。
macOS
$ brew install alp
asdf
$ asdf plugin-add alp https://github.com/asdf-community/asdf-alp.git
$ asdf install alp <バージョン>
$ asdf global alp <バージョン>
サポートしているログフォーマット
alpは以下のログフォーマットをサポートしています。
- LTSV
- JSON
また、解析するログフォーマットを正規表現で記述する機能もあるため、テキストフォーマットであればどのようなフォーマットのログでも解析することができます。
他にも、ログファイルではありませんが pcap ファイルを読み込むこともできます。
設定
alpでアクセスログを集計する前に、集計できるログフォーマットに変更する必要があります。
ドキュメントにログフォーマットごとのApache, Nginx, H2Oの設定例を記載していますのでそちらを参照してください。
使い方
alpはltsv
, json
, regexp
, pcap
, diff
の5つのサブコマンドで構成されています。
$ alp --help
usage: alp [<flags>] <command> [<args> ...]
alp is the access log profiler for LTSV, JSON, Pcap, and others.
Flags:
--help Show context-sensitive help (also try
--help-long and --help-man).
-c, --config=CONFIG The configuration file
--file=FILE The access log file
-d, --dump=DUMP Dump profiled data as YAML
-l, --load=LOAD Load the profiled YAML data
--sort=count Output the results in sorted order
-r, --reverse Sort results in reverse order
-q, --query-string Include the URI query string
--qs-ignore-values Ignore the value of the query string. Replace
all values with xxx (only use with -q)
--decode-uri Decode the URI
--format=table The output format (table, markdown, tsv, csv and html)
--noheaders Output no header line at all (only --format=tsv,
csv)
--show-footers Output footer line at all (only --format=table,
markdown)
--limit=5000 The maximum number of results to display
--location=Local Location name for the timezone
-o, --output=all Specifies the results to display, separated by
commas
-m, --matching-groups=PATTERN,...
Specifies URI matching groups separated by
commas
-f, --filters=FILTERS Only the logs are profiled that match the
conditions
--pos=POSITION_FILE The position file
--nosave-pos Do not save position file
--percentiles="90,95,99" Specifies the percentiles separated by commas
--version Show application version.
Commands:
help [<command>...]
Show help.
ltsv [<flags>]
Profile the logs for LTSV
json [<flags>]
Profile the logs for JSON
regexp [<flags>]
Profile the logs that match a regular expression
pcap [<flags>]
Profile the HTTP requests for captured packets
diff <from> <to>
Show the difference between the two profile results
ISUCON10オンライン予選問題のアクセスログ(JSON)を例に使い方を説明します。
まずは、何もオプションを指定しないで実行します。
$ cat /path/to/access.log | alp json
+-------+-----+-----+-----+-----+-----+--------+------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/recommended_estate/24 | 1.140 | 1.140 | 1.140 | 1.140 | 1.140 | 1.140 | 1.140 | 0.000 | 13253.000 | 13253.000 | 13253.000 | 13253.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/8654 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.000 | 667.000 | 667.000 | 667.000 | 667.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/15302 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.000 | 542.000 | 542.000 | 542.000 | 542.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/53 | 0.008 | 0.008 | 0.008 | 0.008 | 0.008 | 0.008 | 0.008 | 0.000 | 584.000 | 584.000 | 584.000 | 584.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/51 | 0.012 | 0.012 | 0.012 | 0.012 | 0.012 | 0.012 | 0.012 | 0.000 | 615.000 | 615.000 | 615.000 | 615.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/11534 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.000 | 512.000 | 512.000 | 512.000 | 512.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/21 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.000 | 544.000 | 544.000 | 544.000 | 544.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/85 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.000 | 535.000 | 535.000 | 535.000 | 535.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/50 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.000 | 527.000 | 527.000 | 527.000 | 527.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/65 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 486.000 | 486.000 | 486.000 | 486.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/26 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 651.000 | 651.000 | 651.000 | 651.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/76 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 634.000 | 634.000 | 634.000 | 634.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/64 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 638.000 | 638.000 | 638.000 | 638.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/35 | 0.024 | 0.024 | 0.024 | 0.024 | 0.024 | 0.024 | 0.024 | 0.000 | 634.000 | 634.000 | 634.000 | 634.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/recommended_estate/17 | 1.284 | 1.284 | 1.284 | 1.284 | 1.284 | 1.284 | 1.284 | 0.000 | 13430.000 | 13430.000 | 13430.000 | 13430.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/recommended_estate/42 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 0.000 | 13690.000 | 13690.000 | 13690.000 | 13690.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 2 | 0 | 2 | 0 | 0 | 0 | GET | /api/recommended_estate/61 | 0.956 | 0.972 | 1.928 | 0.964 | 0.972 | 0.972 | 0.972 | 0.008 | 13682.000 | 13682.000 | 27364.000 | 13682.000 |
| 2 | 0 | 1 | 0 | 1 | 0 | GET | /api/estate/29501 | 0.004 | 0.004 | 0.004 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 616.000 | 616.000 | 616.000 | 308.000 |
| 4 | 0 | 2 | 0 | 2 | 0 | GET | /api/chair/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 542.000 | 1084.000 | 271.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/chair/search | 0.028 | 0.232 | 2.364 | 0.113 | 0.192 | 0.224 | 0.232 | 0.061 | 33.000 | 20139.000 | 280994.000 | 13380.667 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/estate/search | 0.040 | 0.708 | 4.880 | 0.232 | 0.624 | 0.632 | 0.708 | 0.230 | 728.000 | 27368.000 | 354375.000 | 16875.000 |
+-------+-----+-----+-----+-----+-----+--------+------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
デフォルトでは、COUNT
の昇順でソートし、URIはQuery Stringを省略した状態で集計、テーブル形式で出力します。
アクセスログの集計結果を眺めると、/api/estate/8654
や/api/estate/15302
など、同じようなURIが多いことに気がつきます。これらは、同じhandlerで処理されるので一つのURIとして集計したほうが良いことが多いでしょう。そのようなケースで役立つのが-m
です。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+'
+-------+-----+-----+-----+-----+-----+--------+------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/recommended_estate/42 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 0.000 | 13690.000 | 13690.000 | 13690.000 | 13690.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/11534 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 | 0.000 | 512.000 | 512.000 | 512.000 | 512.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/53 | 0.008 | 0.008 | 0.008 | 0.008 | 0.008 | 0.008 | 0.008 | 0.000 | 584.000 | 584.000 | 584.000 | 584.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/21 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.000 | 544.000 | 544.000 | 544.000 | 544.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/85 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.000 | 535.000 | 535.000 | 535.000 | 535.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/50 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.016 | 0.000 | 527.000 | 527.000 | 527.000 | 527.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/recommended_estate/17 | 1.284 | 1.284 | 1.284 | 1.284 | 1.284 | 1.284 | 1.284 | 0.000 | 13430.000 | 13430.000 | 13430.000 | 13430.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/65 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 486.000 | 486.000 | 486.000 | 486.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/recommended_estate/24 | 1.140 | 1.140 | 1.140 | 1.140 | 1.140 | 1.140 | 1.140 | 0.000 | 13253.000 | 13253.000 | 13253.000 | 13253.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 2 | 0 | 2 | 0 | 0 | 0 | GET | /api/recommended_estate/61 | 0.956 | 0.972 | 1.928 | 0.964 | 0.972 | 0.972 | 0.972 | 0.008 | 13682.000 | 13682.000 | 27364.000 | 13682.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 4 | 0 | 2 | 0 | 2 | 0 | GET | /api/chair/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 542.000 | 1084.000 | 271.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 9 | 0 | 8 | 0 | 1 | 0 | GET | /api/estate/[0-9]+ | 0.004 | 0.024 | 0.108 | 0.012 | 0.024 | 0.024 | 0.024 | 0.009 | 542.000 | 667.000 | 4997.000 | 555.222 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/estate/search | 0.040 | 0.708 | 4.880 | 0.232 | 0.624 | 0.632 | 0.708 | 0.230 | 728.000 | 27368.000 | 354375.000 | 16875.000 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/chair/search | 0.028 | 0.232 | 2.364 | 0.113 | 0.192 | 0.224 | 0.232 | 0.061 | 33.000 | 20139.000 | 280994.000 | 13380.667 |
+-------+-----+-----+-----+-----+-----+--------+------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
/api/estate/8654
や/api/estate/15302
などが/api/estate/[0-9]+
にまとめられています。このように-m
は正規表現にマッチしたURIをひとつのURIとして集計する機能です。カンマ区切りで複数指定することも可能です。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+,/api/chair/[0-9]+,/api/recommended_estate/[0-9]+'
+-------+-----+-----+-----+-----+-----+--------+--------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+--------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/recommended_estate/[0-9]+ | 0.956 | 1.284 | 5.352 | 1.070 | 1.284 | 1.284 | 1.284 | 0.125 | 13253.000 | 13690.000 | 67737.000 | 13547.400 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 9 | 0 | 8 | 0 | 1 | 0 | GET | /api/estate/[0-9]+ | 0.004 | 0.024 | 0.108 | 0.012 | 0.024 | 0.024 | 0.024 | 0.009 | 542.000 | 667.000 | 4997.000 | 555.222 |
| 10 | 0 | 8 | 0 | 2 | 0 | GET | /api/chair/[0-9]+ | 0.004 | 0.020 | 0.080 | 0.008 | 0.016 | 0.020 | 0.020 | 0.008 | 512.000 | 584.000 | 4272.000 | 427.200 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/estate/search | 0.040 | 0.708 | 4.880 | 0.232 | 0.624 | 0.632 | 0.708 | 0.230 | 728.000 | 27368.000 | 354375.000 | 16875.000 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/chair/search | 0.028 | 0.232 | 2.364 | 0.113 | 0.192 | 0.224 | 0.232 | 0.061 | 33.000 | 20139.000 | 280994.000 | 13380.667 |
+-------+-----+-----+-----+-----+-----+--------+--------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
集計結果をAverageごと、さらに降順でソートしたいときは--sort avg
と-r
を使います。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+,/api/chair/[0-9]+,/api/recommended_estate/[0-9]+' --sort avg -r
+-------+-----+-----+-----+-----+-----+--------+--------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+--------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/recommended_estate/[0-9]+ | 0.956 | 1.284 | 5.352 | 1.070 | 1.284 | 1.284 | 1.284 | 0.125 | 13253.000 | 13690.000 | 67737.000 | 13547.400 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/estate/search | 0.040 | 0.708 | 4.880 | 0.232 | 0.624 | 0.632 | 0.708 | 0.230 | 728.000 | 27368.000 | 354375.000 | 16875.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 21 | 0 | 21 | 0 | 0 | 0 | GET | /api/chair/search | 0.028 | 0.232 | 2.364 | 0.113 | 0.192 | 0.224 | 0.232 | 0.061 | 33.000 | 20139.000 | 280994.000 | 13380.667 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 9 | 0 | 8 | 0 | 1 | 0 | GET | /api/estate/[0-9]+ | 0.004 | 0.024 | 0.108 | 0.012 | 0.024 | 0.024 | 0.024 | 0.009 | 542.000 | 667.000 | 4997.000 | 555.222 |
| 10 | 0 | 8 | 0 | 2 | 0 | GET | /api/chair/[0-9]+ | 0.004 | 0.020 | 0.080 | 0.008 | 0.016 | 0.020 | 0.020 | 0.008 | 512.000 | 584.000 | 4272.000 | 427.200 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-----+-----+-----+-----+--------+--------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
--sort
にはcount
とavg
以外にも様々な値を指定できます。詳細はドキュメントを参照してください。
これまでの集計結果のURIに/api/chair/search
がありますが、アクセスログを見るとQuery Stringが含まれています。Query Stringまで含めて集計対象とする場合は-q
を使います。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+,/api/chair/[0-9]+,/api/recommended_estate/[0-9]+' --sort avg -r -q
+-------+-----+-----+-----+-----+-----+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/recommended_estate/[0-9]+ | 0.956 | 1.284 | 5.352 | 1.070 | 1.284 | 1.284 | 1.284 | 0.125 | 13253.000 | 13690.000 | 67737.000 | 13547.400 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?features=%E3%83%9A%E3%83%83%E3%83%88%E7%9B%B8%E8%AB%87%E5%8F%AF%2C%E3%83%AD%E3%83%95%E3%83%88&page=0&perPage=23 | 0.708 | 0.708 | 0.708 | 0.708 | 0.708 | 0.708 | 0.708 | 0.000 | 14925.000 | 14925.000 | 14925.000 | 14925.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?features=%E3%83%A1%E3%82%BE%E3%83%8D%E3%83%83%E3%83%88%2C%E3%83%90%E3%82%A4%E3%82%AF%E7%BD%AE%E5%A0%B4%E3%81%82%E3%82%8A%2CTV%E3%83%A2%E3%83%8B%E3%82%BF%E4%BB%98%E3%81%8D%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%9B%E3%83%B3&page=0&perPage=44 | 0.632 | 0.632 | 0.632 | 0.632 | 0.632 | 0.632 | 0.632 | 0.000 | 728.000 | 728.000 | 728.000 | 728.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?features=TV%E3%83%A2%E3%83%8B%E3%82%BF%E4%BB%98%E3%81%8D%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%9B%E3%83%B3&page=0&perPage=39&rentRangeId=1 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.000 | 27368.000 | 27368.000 | 27368.000 | 27368.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?features=%E6%95%B7%E5%9C%B0%E5%86%85%E9%A7%90%E8%BB%8A%E5%A0%B4&page=0&perPage=27 | 0.616 | 0.616 | 0.616 | 0.616 | 0.616 | 0.616 | 0.616 | 0.000 | 18569.000 | 18569.000 | 18569.000 | 18569.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorWidthRangeId=0&features=%E6%B4%97%E9%9D%A2%E6%89%80%E7%8B%AC%E7%AB%8B&page=0&perPage=37&rentRangeId=1 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.000 | 25478.000 | 25478.000 | 25478.000 | 25478.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=%E3%83%97%E3%83%A9%E3%82%B9%E3%83%81%E3%83%83%E3%82%AF%E8%A3%BD%2C%E4%BD%8E%E5%8F%8D%E7%99%BA&page=0&perPage=46 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.000 | 5482.000 | 5482.000 | 5482.000 | 5482.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?depthRangeId=3&features=%E3%83%AB%E3%83%8D%E3%82%B5%E3%83%B3%E3%82%B9%E7%9A%84%E3%81%AA%E3%83%87%E3%82%B6%E3%82%A4%E3%83%B3&page=0&perPage=32&widthRangeId=3 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.000 | 20139.000 | 20139.000 | 20139.000 | 20139.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=%E8%82%98%E6%8E%9B%E3%81%91%E4%BB%98%E3%81%8D%2C%E3%83%AC%E3%82%B6%E3%83%BC%E8%A3%BD%2C%E4%BD%8E%E5%8F%8D%E7%99%BA&page=0&perPage=37&priceRangeId=1 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.000 | 33.000 | 33.000 | 33.000 | 33.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=%E3%83%99%E3%83%83%E3%83%89%E4%B8%80%E4%BD%93%E5%9E%8B&kind=%E3%83%8F%E3%83%B3%E3%83%A2%E3%83%83%E3%82%AF&page=0&perPage=25 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.000 | 15221.000 | 15221.000 | 15221.000 | 15221.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=3&page=4&perPage=25 | 0.180 | 0.180 | 0.180 | 0.180 | 0.180 | 0.180 | 0.180 | 0.000 | 14839.000 | 14839.000 | 14839.000 | 14839.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?page=3&perPage=25&rentRangeId=3 | 0.176 | 0.176 | 0.176 | 0.176 | 0.176 | 0.176 | 0.176 | 0.000 | 16695.000 | 16695.000 | 16695.000 | 16695.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=2&page=0&perPage=25 | 0.168 | 0.168 | 0.168 | 0.168 | 0.168 | 0.168 | 0.168 | 0.000 | 16894.000 | 16894.000 | 16894.000 | 16894.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=3&page=1&perPage=25 | 0.136 | 0.136 | 0.136 | 0.136 | 0.136 | 0.136 | 0.136 | 0.000 | 14977.000 | 14977.000 | 14977.000 | 14977.000 |
| 3 | 0 | 3 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=3&page=0&perPage=25 | 0.128 | 0.140 | 0.396 | 0.132 | 0.140 | 0.140 | 0.140 | 0.006 | 15027.000 | 15041.000 | 45109.000 | 15036.333 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=3&page=3&perPage=25 | 0.128 | 0.128 | 0.128 | 0.128 | 0.128 | 0.128 | 0.128 | 0.000 | 14741.000 | 14741.000 | 14741.000 | 14741.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=2&page=1&perPage=25 | 0.124 | 0.124 | 0.124 | 0.124 | 0.124 | 0.124 | 0.124 | 0.000 | 16740.000 | 16740.000 | 16740.000 | 16740.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?color=%E3%83%8D%E3%82%A4%E3%83%93%E3%83%BC&features=%E3%82%A2%E3%83%B3%E3%83%86%E3%82%A3%E3%83%BC%E3%82%AF%2C%E3%83%87%E3%82%A3%E3%82%B9%E3%83%97%E3%83%AC%E3%82%A4%E9%85%8D%E7%BD%AE%E5%8F%AF%E8%83%BD%2C%E3%82%AF%E3%83%83%E3%82%B7%E3%83%A7%E3%83%B3%E6%80%A7%E6%8A%9C%E7%BE%A4&page=0&perPage=33 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.000 | 33.000 | 33.000 | 33.000 | 33.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?page=4&perPage=25&rentRangeId=3 | 0.116 | 0.116 | 0.116 | 0.116 | 0.116 | 0.116 | 0.116 | 0.000 | 16859.000 | 16859.000 | 16859.000 | 16859.000 |
| 2 | 0 | 2 | 0 | 0 | 0 | GET | /api/estate/search?page=0&perPage=25&rentRangeId=2 | 0.040 | 0.152 | 0.192 | 0.096 | 0.152 | 0.152 | 0.152 | 0.056 | 16769.000 | 16791.000 | 33560.000 | 16780.000 |
| 3 | 0 | 3 | 0 | 0 | 0 | GET | /api/estate/search?page=4&perPage=25&rentRangeId=2 | 0.084 | 0.116 | 0.288 | 0.096 | 0.116 | 0.116 | 0.116 | 0.014 | 16456.000 | 16456.000 | 49368.000 | 16456.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?page=4&perPage=25&rentRangeId=1 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.000 | 16740.000 | 16740.000 | 16740.000 | 16740.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=0&page=3&perPage=25 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.000 | 16349.000 | 16349.000 | 16349.000 | 16349.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=0&page=0&perPage=25 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.000 | 16738.000 | 16738.000 | 16738.000 | 16738.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=0&page=1&perPage=25 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.092 | 0.000 | 16802.000 | 16802.000 | 16802.000 | 16802.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?page=0&perPage=25&rentRangeId=1 | 0.088 | 0.088 | 0.088 | 0.088 | 0.088 | 0.088 | 0.088 | 0.000 | 16634.000 | 16634.000 | 16634.000 | 16634.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?kind=%E5%BA%A7%E6%A4%85%E5%AD%90&page=0&perPage=25 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.000 | 14624.000 | 14624.000 | 14624.000 | 14624.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?page=0&perPage=25&rentRangeId=3 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.000 | 17241.000 | 17241.000 | 17241.000 | 17241.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?page=1&perPage=25&rentRangeId=1 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.084 | 0.000 | 16687.000 | 16687.000 | 16687.000 | 16687.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?kind=%E5%BA%A7%E6%A4%85%E5%AD%90&page=2&perPage=25 | 0.080 | 0.080 | 0.080 | 0.080 | 0.080 | 0.080 | 0.080 | 0.000 | 14819.000 | 14819.000 | 14819.000 | 14819.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?kind=%E5%BA%A7%E6%A4%85%E5%AD%90&page=1&perPage=25 | 0.080 | 0.080 | 0.080 | 0.080 | 0.080 | 0.080 | 0.080 | 0.000 | 14934.000 | 14934.000 | 14934.000 | 14934.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=1&page=2&perPage=25 | 0.068 | 0.068 | 0.068 | 0.068 | 0.068 | 0.068 | 0.068 | 0.000 | 15016.000 | 15016.000 | 15016.000 | 15016.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?kind=%E3%82%A8%E3%83%AB%E3%82%B4%E3%83%8E%E3%83%9F%E3%82%AF%E3%82%B9&page=2&perPage=25 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.000 | 15135.000 | 15135.000 | 15135.000 | 15135.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?kind=%E3%82%A8%E3%83%AB%E3%82%B4%E3%83%8E%E3%83%9F%E3%82%AF%E3%82%B9&page=0&perPage=25 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.000 | 15241.000 | 15241.000 | 15241.000 | 15241.000 |
| 2 | 0 | 2 | 0 | 0 | 0 | GET | /api/chair/search?page=0&perPage=25&priceRangeId=4 | 0.044 | 0.044 | 0.088 | 0.044 | 0.044 | 0.044 | 0.044 | 0.000 | 15275.000 | 15275.000 | 30550.000 | 15275.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=1&page=1&perPage=25 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 15173.000 | 15173.000 | 15173.000 | 15173.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=1&page=0&perPage=25 | 0.028 | 0.028 | 0.028 | 0.028 | 0.028 | 0.028 | 0.028 | 0.000 | 14928.000 | 14928.000 | 14928.000 | 14928.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 9 | 0 | 8 | 0 | 1 | 0 | GET | /api/estate/[0-9]+ | 0.004 | 0.024 | 0.108 | 0.012 | 0.024 | 0.024 | 0.024 | 0.009 | 542.000 | 667.000 | 4997.000 | 555.222 |
| 10 | 0 | 8 | 0 | 2 | 0 | GET | /api/chair/[0-9]+ | 0.004 | 0.020 | 0.080 | 0.008 | 0.016 | 0.020 | 0.020 | 0.008 | 512.000 | 584.000 | 4272.000 | 427.200 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-----+-----+-----+-----+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
URIに/api/chair/search?heightRangeId=1&page=1&perPage=25
などが出力されるようになりました。
Query Stringのキーだけを見て、全てのキーが一致していたら値に関係なく同一URIとして集計したい場合があるかもしれません。そのようなときは、-q
と一緒に--qs-ignore-values
を使います。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+,/api/chair/[0-9]+,/api/recommended_estate/[0-9]+' --sort avg -r -q --qs-ignore-values
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/recommended_estate/[0-9]+ | 0.956 | 1.284 | 5.352 | 1.070 | 1.284 | 1.284 | 1.284 | 0.125 | 13253.000 | 13690.000 | 67737.000 | 13547.400 |
| 3 | 0 | 3 | 0 | 0 | 0 | GET | /api/estate/search?features=xxx&page=xxx&perPage=xxx | 0.616 | 0.708 | 1.956 | 0.652 | 0.708 | 0.708 | 0.708 | 0.040 | 728.000 | 18569.000 | 34222.000 | 11407.333 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?features=xxx&page=xxx&perPage=xxx&rentRangeId=xxx | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.000 | 27368.000 | 27368.000 | 27368.000 | 27368.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorWidthRangeId=xxx&features=xxx&page=xxx&perPage=xxx&rentRangeId=xxx | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.000 | 25478.000 | 25478.000 | 25478.000 | 25478.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=xxx&page=xxx&perPage=xxx | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.000 | 5482.000 | 5482.000 | 5482.000 | 5482.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?depthRangeId=xxx&features=xxx&page=xxx&perPage=xxx&widthRangeId=xxx | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.000 | 20139.000 | 20139.000 | 20139.000 | 20139.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=xxx&page=xxx&perPage=xxx&priceRangeId=xxx | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.000 | 33.000 | 33.000 | 33.000 | 33.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=xxx&kind=xxx&page=xxx&perPage=xxx | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.000 | 15221.000 | 15221.000 | 15221.000 | 15221.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?color=xxx&features=xxx&page=xxx&perPage=xxx | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.000 | 33.000 | 33.000 | 33.000 | 33.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=xxx&page=xxx&perPage=xxx | 0.092 | 0.168 | 0.568 | 0.114 | 0.168 | 0.168 | 0.168 | 0.030 | 16349.000 | 16894.000 | 83523.000 | 16704.600 |
| 9 | 0 | 9 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=xxx&page=xxx&perPage=xxx | 0.028 | 0.180 | 0.968 | 0.108 | 0.180 | 0.180 | 0.180 | 0.049 | 14741.000 | 15173.000 | 134783.000 | 14975.889 |
| 11 | 0 | 11 | 0 | 0 | 0 | GET | /api/estate/search?page=xxx&perPage=xxx&rentRangeId=xxx | 0.040 | 0.176 | 1.120 | 0.102 | 0.152 | 0.176 | 0.176 | 0.035 | 16456.000 | 17241.000 | 183784.000 | 16707.636 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/chair/search?kind=xxx&page=xxx&perPage=xxx | 0.056 | 0.084 | 0.356 | 0.071 | 0.084 | 0.084 | 0.084 | 0.012 | 14624.000 | 15241.000 | 74753.000 | 14950.600 |
| 2 | 0 | 2 | 0 | 0 | 0 | GET | /api/chair/search?page=xxx&perPage=xxx&priceRangeId=xxx | 0.044 | 0.044 | 0.088 | 0.044 | 0.044 | 0.044 | 0.044 | 0.000 | 15275.000 | 15275.000 | 30550.000 | 15275.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 9 | 0 | 8 | 0 | 1 | 0 | GET | /api/estate/[0-9]+ | 0.004 | 0.024 | 0.108 | 0.012 | 0.024 | 0.024 | 0.024 | 0.009 | 542.000 | 667.000 | 4997.000 | 555.222 |
| 10 | 0 | 8 | 0 | 2 | 0 | GET | /api/chair/[0-9]+ | 0.004 | 0.020 | 0.080 | 0.008 | 0.016 | 0.020 | 0.020 | 0.008 | 512.000 | 584.000 | 4272.000 | 427.200 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
アクセス数はどれくらいで、HTTPステータスコードごとだとどれくらいかを知りたいときは--show-footers
を使うと出力できます。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+,/api/chair/[0-9]+,/api/recommended_estate/[0-9]+' --sort avg -r -q --qs-ignore-values --show-footers
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD | URI | MIN | MAX | SUM | AVG | P90 | P95 | P99 | STDDEV | MIN(BODY) | MAX(BODY) | SUM(BODY) | AVG(BODY) |
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /initialize | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 | 0.000 | 23.000 | 23.000 | 23.000 | 23.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/recommended_estate/[0-9]+ | 0.956 | 1.284 | 5.352 | 1.070 | 1.284 | 1.284 | 1.284 | 0.125 | 13253.000 | 13690.000 | 67737.000 | 13547.400 |
| 3 | 0 | 3 | 0 | 0 | 0 | GET | /api/estate/search?features=xxx&page=xxx&perPage=xxx | 0.616 | 0.708 | 1.956 | 0.652 | 0.708 | 0.708 | 0.708 | 0.040 | 728.000 | 18569.000 | 34222.000 | 11407.333 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?features=xxx&page=xxx&perPage=xxx&rentRangeId=xxx | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 | 0.000 | 27368.000 | 27368.000 | 27368.000 | 27368.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/estate/search?doorWidthRangeId=xxx&features=xxx&page=xxx&perPage=xxx&rentRangeId=xxx | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 | 0.000 | 25478.000 | 25478.000 | 25478.000 | 25478.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=xxx&page=xxx&perPage=xxx | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 | 0.000 | 5482.000 | 5482.000 | 5482.000 | 5482.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?depthRangeId=xxx&features=xxx&page=xxx&perPage=xxx&widthRangeId=xxx | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 | 0.000 | 20139.000 | 20139.000 | 20139.000 | 20139.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | POST | /api/estate/nazotte | 0.024 | 0.404 | 1.056 | 0.211 | 0.404 | 0.404 | 0.404 | 0.152 | 34.000 | 33925.000 | 67433.000 | 13486.600 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=xxx&page=xxx&perPage=xxx&priceRangeId=xxx | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 | 0.000 | 33.000 | 33.000 | 33.000 | 33.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?features=xxx&kind=xxx&page=xxx&perPage=xxx | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 | 0.000 | 15221.000 | 15221.000 | 15221.000 | 15221.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | GET | /api/chair/search?color=xxx&features=xxx&page=xxx&perPage=xxx | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 | 0.000 | 33.000 | 33.000 | 33.000 | 33.000 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/estate/search?doorHeightRangeId=xxx&page=xxx&perPage=xxx | 0.092 | 0.168 | 0.568 | 0.114 | 0.168 | 0.168 | 0.168 | 0.030 | 16349.000 | 16894.000 | 83523.000 | 16704.600 |
| 9 | 0 | 9 | 0 | 0 | 0 | GET | /api/chair/search?heightRangeId=xxx&page=xxx&perPage=xxx | 0.028 | 0.180 | 0.968 | 0.108 | 0.180 | 0.180 | 0.180 | 0.049 | 14741.000 | 15173.000 | 134783.000 | 14975.889 |
| 11 | 0 | 11 | 0 | 0 | 0 | GET | /api/estate/search?page=xxx&perPage=xxx&rentRangeId=xxx | 0.040 | 0.176 | 1.120 | 0.102 | 0.152 | 0.176 | 0.176 | 0.035 | 16456.000 | 17241.000 | 183784.000 | 16707.636 |
| 5 | 0 | 5 | 0 | 0 | 0 | GET | /api/chair/search?kind=xxx&page=xxx&perPage=xxx | 0.056 | 0.084 | 0.356 | 0.071 | 0.084 | 0.084 | 0.084 | 0.012 | 14624.000 | 15241.000 | 74753.000 | 14950.600 |
| 2 | 0 | 2 | 0 | 0 | 0 | GET | /api/chair/search?page=xxx&perPage=xxx&priceRangeId=xxx | 0.044 | 0.044 | 0.088 | 0.044 | 0.044 | 0.044 | 0.044 | 0.000 | 15275.000 | 15275.000 | 30550.000 | 15275.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 9 | 0 | 8 | 0 | 1 | 0 | GET | /api/estate/[0-9]+ | 0.004 | 0.024 | 0.108 | 0.012 | 0.024 | 0.024 | 0.024 | 0.009 | 542.000 | 667.000 | 4997.000 | 555.222 |
| 10 | 0 | 8 | 0 | 2 | 0 | GET | /api/chair/[0-9]+ | 0.004 | 0.020 | 0.080 | 0.008 | 0.016 | 0.020 | 0.020 | 0.008 | 512.000 | 584.000 | 4272.000 | 427.200 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/estate/low_priced | 0.000 | 0.016 | 0.036 | 0.005 | 0.016 | 0.016 | 0.016 | 0.005 | 13397.000 | 13397.000 | 107176.000 | 13397.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | GET | /api/chair/low_priced | 0.000 | 0.020 | 0.020 | 0.003 | 0.020 | 0.020 | 0.020 | 0.007 | 12153.000 | 12153.000 | 97224.000 | 12153.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/chair/search/condition | 0.000 | 0.004 | 0.008 | 0.002 | 0.004 | 0.004 | 0.004 | 0.002 | 3392.000 | 3392.000 | 13568.000 | 3392.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | GET | /api/estate/search/condition | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 | 0.004 | 0.004 | 0.002 | 2563.000 | 2563.000 | 10252.000 | 2563.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/chair/buy/29501 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | POST | /api/estate/req_doc/8654 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
| 100 | 0 | 97 | 0 | 3 | 0 |
+-------+-----+-----+-----+-----+-----+--------+-------------------------------------------------------------------------------------------+-------+-------+-------+-------+-------+-------+-------+--------+-----------+-----------+------------+-----------+
横に広すぎて見にくいので情報量を減らしたいというときは-o
が使えます。
$ cat /path/to/access.log | alp json -m '/api/estate/[0-9]+,/api/chair/[0-9]+,/api/recommended_estate/[0-9]+' --sort avg -r --show-footers -o count,1xx,2xx,3xx,4xx,5xx,min,max,avg,sum,p99
+-------+-----+-----+-----+-----+-----+-------+-------+-------+-------+-------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | MIN | MAX | AVG | SUM | P99 |
+-------+-----+-----+-----+-----+-----+-------+-------+-------+-------+-------+
| 1 | 0 | 1 | 0 | 0 | 0 | 7.524 | 7.524 | 7.524 | 7.524 | 7.524 |
| 5 | 0 | 5 | 0 | 0 | 0 | 0.956 | 1.284 | 1.070 | 5.352 | 1.140 |
| 3 | 0 | 3 | 0 | 0 | 0 | 0.616 | 0.708 | 0.652 | 1.956 | 0.632 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.624 | 0.624 | 0.624 | 0.624 | 0.624 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.612 | 0.612 | 0.612 | 0.612 | 0.612 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.232 | 0.232 | 0.232 | 0.232 | 0.232 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.224 | 0.224 | 0.224 | 0.224 | 0.224 |
| 5 | 0 | 5 | 0 | 0 | 0 | 0.024 | 0.404 | 0.211 | 1.056 | 0.328 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.192 | 0.192 | 0.192 | 0.192 | 0.192 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.184 | 0.184 | 0.184 | 0.184 | 0.184 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.120 | 0.120 | 0.120 | 0.120 | 0.120 |
| 5 | 0 | 5 | 0 | 0 | 0 | 0.092 | 0.168 | 0.114 | 0.568 | 0.168 |
| 9 | 0 | 9 | 0 | 0 | 0 | 0.028 | 0.180 | 0.108 | 0.968 | 0.180 |
| 11 | 0 | 11 | 0 | 0 | 0 | 0.040 | 0.176 | 0.102 | 1.120 | 0.116 |
| 5 | 0 | 5 | 0 | 0 | 0 | 0.056 | 0.084 | 0.071 | 0.356 | 0.056 |
| 2 | 0 | 2 | 0 | 0 | 0 | 0.044 | 0.044 | 0.044 | 0.088 | 0.044 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.032 | 0.032 | 0.032 | 0.032 | 0.032 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 |
| 9 | 0 | 8 | 0 | 1 | 0 | 0.004 | 0.024 | 0.012 | 0.108 | 0.004 |
| 10 | 0 | 8 | 0 | 2 | 0 | 0.004 | 0.020 | 0.008 | 0.080 | 0.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | 0.000 | 0.016 | 0.005 | 0.036 | 0.000 |
| 8 | 0 | 8 | 0 | 0 | 0 | 0.000 | 0.020 | 0.003 | 0.020 | 0.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | 0.000 | 0.004 | 0.002 | 0.008 | 0.000 |
| 4 | 0 | 4 | 0 | 0 | 0 | 0.000 | 0.004 | 0.001 | 0.004 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-----+-----+-----+-----+-------+-------+-------+-------+-------+
| 100 | 0 | 97 | 0 | 3 | 0 |
+-------+-----+-----+-----+-----+-----+-------+-------+-------+-------+-------+
このようにカンマ区切りで指定できます。指定できる値はドキュメントを参照してください。
まとめ
ISUCON10オンライン予選問題のアクセスログを例にalpの基本的な使い方を紹介しました。
ISUCONに参加する方もそうでない方にも役立てば幸いです。
要望があればGitHub Issueか本記事にコメントお願いします。また、PullRequestも歓迎しています!
Discussion