Grafana Cloud k6 REST API v5
The Grafana Cloud k6 REST API provides programmatic access to test results.
Authentication
This API uses token-based authentication.
Make all requests with an Authorization:
HTTP header with value of Token <your-token>
.
GET https://api.k6.io/cloud/v5/projects
Authorization: Token 56c166885f9a7fc1e579a1b3cb66f6dd
Refer to Authenticate on the CLI to get your API token.
API reference
Root URL for the v5 API version is:
https://api.k6.io/cloud/v5
See following pages for reference on available endpoints:
API endpoints cheat sheet
The following sections provide some examples of common requests. Please consult reference pages for full descriptions of endpoints and parameters.
Query test run aggregate values
Get the total number of HTTP requests made during the test run:
/test_runs/:testRunId/query_aggregate_k6(metric='http_reqs',query='increase')
Get the number of HTTP requests made within a specific time period:
/test_runs/:testRunId/query_aggregate_k6(metric='http_reqs',query='increase',start=2021-08-09T12:01:10Z,end=2021-08-09T12:09:13Z)
Get the 95th percentile of HTTP request response times, separated by URL, HTTP method, and HTTP status code:
/test_runs/:testRunId/query_aggregate_k6(metric='http_req_duration',query='historgam_quantile(0.95) by (name,method,status)')
Get the peak requests per second during the test run with 5 second precision, for requests with statuses 2xx and 3xx, separated by URL:
/test_runs/:testRunId/query_aggregate_k6(metric='http_reqs{status~="[23][0-9]{2}"}',query='max_rate(5) by (name)')
Get peak CPU usage of each instance during test run, averaged between instances:
/test_runs/:testRunId/query_aggregate_k6(metric='load_generator_cpu_percent',query='avg(max by (instance))')
Get peak simultaneous VUs during the test run:
/test_runs/:testRunId/query_aggregate_k6(metric='vus',query='sum(max by (instance_id))')
Query test run range values
Get a chart of simultaneous VUs during the test run:
/test_runs/:testRunId/query_range_k6(metric='vus',query='sum(last by (instance_id))')
Get a chart of requests per second:
/test_runs/:testRunId/query_range_k6(metric='http_reqs',query='rate')
Get a chart of requests per second, excluding network errors (where status
equals to "0"
), separated by URL and HTTP method:
/test_runs/:testRunId/query_range_k6(metric='http_reqs{status!="0"}',query='rate by (name,method)')
Get a chart of the 95th percentile of HTTP request response times, separated by URL, HTTP method, and HTTP status code, with 10 second resolution, and filtered for a specific time range:
/test_runs/:testRunId/query_range_k6(metric='http_req_duration',query='histogram_quantile(0.95) by (name,method,status)',step=10,start=2021-08-09T12:01:10Z,end=2021-08-09T12:09:13Z)