|
| 1 | +--- |
| 2 | +title: 'CSV' |
| 3 | +excerpt: '' |
| 4 | +--- |
| 5 | + |
| 6 | +You can also make k6 output detailed statistics in a CSV format by using the `--out`/`-o` option for `k6 run`, like this: |
| 7 | + |
| 8 | +<div class="code-group" data-props='{"labels": ["CLI"]}'> |
| 9 | + |
| 10 | +```shell |
| 11 | +$ k6 run --out csv=my_test_result.csv script.js |
| 12 | +``` |
| 13 | + |
| 14 | +</div> |
| 15 | + |
| 16 | +Or if you want to get the result gzipped, like this: |
| 17 | + |
| 18 | +<div class="code-group" data-props='{"labels": ["CLI"]}'> |
| 19 | + |
| 20 | +```shell |
| 21 | +$ k6 run --out csv=my_test_result.gz script.js |
| 22 | +``` |
| 23 | + |
| 24 | +</div> |
| 25 | + |
| 26 | +## CSV format |
| 27 | + |
| 28 | +The CSV result file will contain lines like these: |
| 29 | + |
| 30 | +<div class="code-group" data-props='{"labels": ["Output"]}'> |
| 31 | + |
| 32 | +```csv |
| 33 | +metric_name,timestamp,metric_value,check,error,error_code,group,method,name,proto,scenario,status,subproto,tls_version,url,extra_tags |
| 34 | +http_reqs,1595325560,1.000000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 35 | +http_req_duration,1595325560,221.899000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 36 | +http_req_blocked,1595325560,225.275000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 37 | +http_req_connecting,1595325560,217.680000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 38 | +http_req_tls_handshaking,1595325560,0.000000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 39 | +http_req_sending,1595325560,0.112000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 40 | +http_req_waiting,1595325560,220.280000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 41 | +http_req_receiving,1595325560,1.507000,,,,,GET,http://test.k6.io,HTTP/1.1,default,200,,,http://test.k6.io, |
| 42 | +vus,1595325560,1.000000,,,,,,,,,,,,, |
| 43 | +vus_max,1595325560,20.000000,,,,,,,,,,,,, |
| 44 | +checks,1595325561,1.000000,status is 200,,,,,,,default,,,,, |
| 45 | +checks,1595325561,0.000000,response body,,,,,,,default,,,,, |
| 46 | +data_sent,1595325561,76.000000,,,,,,,,default,,,,, |
| 47 | +data_received,1595325561,11045.000000,,,,,,,,default,,,,, |
| 48 | +iteration_duration,1595325561,1449.049580,,,,,,,,default,,,,, |
| 49 | +iterations,1595325561,1.000000,,,,,,,,default,,,,, |
| 50 | +``` |
| 51 | + |
| 52 | +</div> |
| 53 | + |
| 54 | +Each entry in the report represents a metric `metric_name` along with its value `metric_value` at time `timestamp`. If there's an error, then the `error` along with the `error_code` fields will be populated. |
| 55 | + |
| 56 | + |
| 57 | +## See also |
| 58 | + |
| 59 | +- [Metrics](/using-k6/metrics) |
| 60 | +- [Error codes](https://k6.io/docs/javascript-api/error-codes) |
0 commit comments