Menu
Grafana Cloud RSS

Grafana Cloud k6 REST API

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>.

http
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 current 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.

Read projects

List projects available to the user or organization token:

/projects
/projects?$top=10&$skip=10&$count=true&$orderby=name
/projects/:projectId

Read load tests

List load tests in a project and retrieve individual load test:

/projects/:projectId/load_tests
/projects/:projectId/load_tests?$top=10&$skip=10&$count=true&$orderby=created desc
/projects/:projectId/load_tests?$select=id,name,created

/load_tests/:loadTestId
/load_tests/:loadTestId?$select=id,name,created

Read test runs

List test runs for a particular load test and retrieve individual test run data:

/load_tests/:loadTestId/test_runs
/load_tests/:loadTestId/test_runs?$top=10&$skip=10&$count=true&$orderby=created desc
/test_runs/:testRunId?$select=id,created

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)