Test Run Metrics Legacy API
Warning
The Legacy REST API is no longer under active development. It should not be used except when it provides capabilities not yet offered by the Grafana Cloud k6 REST API.
List metrics
Returns all metrics within a specified test run.
You can get test-run ids from the test_run_ids
field in responses from the Read Test endpoint, or from the id
field in the response from the Start
Test Run endpoint.
Note that cloud service might store multiple (sub)metrics for each metric generated in the k6 script. For example, when sending an HTTP request within the
script, the cloud stores http_req_duration
, http_req_blocked
, http_req_connecting
and other metrics for that particular endpoint.
Differing HTTP methods and statuses are all grouped as separate metrics.
(The same URL produces multiple metrics if k6 detects statuses such as 200, 400 etc).
Some of the fields contained in the response are:
check_id
- ID of thecheck
defined ink6
script. Checks have their underlying metrics stored in the cloud service.group_id
- ID of thegroup
this metric belongs to.contains
- “Unit” for the metrics. Some examples are:time
,percent
,bytes
et.
GET https://api.k6.io/loadtests/v2/metrics?test_run_id={test_run_id}
{
"k6-metrics": [
{
"check_id": "6b1033e4a2021d21a3e856a53b3e7130",
"contains": "default",
"group_id": "24f16e4b60535af8fd5ce494947b8a59",
"id": "d9b21849a4ee9c3b67c30cfe6993ae6a",
"name": "http_req_duration",
"project_id": 123,
"tags": {
"method": "GET",
"status": "200",
"url": "https://test.k6.io"
},
"test_run_id": 103054,
"type": "trend",
"url_id": "string"
}
]
}
Read metric
Returns details of a metric with the specified ID.
GET https://api.k6.io/loadtests/v2/metrics/{id}
{
"k6-check": {
"id": "ec92813ef1d5149e1e789147349e2823",
"name": "LI_DISTRIBUTION"
},
"k6-metric": {
"check_id": "6b1033e4a2021d21a3e856a53b3e7130",
"contains": "default",
"group_id": "24f16e4b60535af8fd5ce494947b8a59",
"id": "d9b21849a4ee9c3b67c30cfe6993ae6a",
"name": "http_req_duration",
"project_id": 123,
"tags": {},
"test_run_id": 103054,
"type": "trend",
"url_id": "string"
},
"k6-group": {
"id": "223813452fd767e624ba9ee6c78bde91",
"name": "page_1 - http://test.k6.io/"
},
"k6-url": {
"id": "81414ab976a1985f59b321d6b745d2c2",
"method": "GET",
"status": 200,
"url": "http://test.k6.io/"
}
}
Read series data
Returns time-series data points for specified metrics ids within a specified test run id. Test run ids are
available in the test_run_ids
field of a response from Read Test
or in the id
field of a response
from Start Test Run
endpoint.
Metric ids are available in the id
field of the response from the
List metrics endpoint.
GET https://api.k6.io/loadtests/v2/series?test_run_id={test_run_id}&ids[]={metric_id_1}
{
"k6-serie": [
{
"agg": {},
"id": "4fa31be7e216ae5335bb5d4ac56931a3",
"method": "mean",
"metric_id": "d9b21849a4ee9c3b67c30cfe6993ae6a",
"test_run_id": 103054,
"values": [
{
"timestamp": "2020-08-13T18:28:45Z",
"value": 0
}
]
}
]
}
List thresholds
Returns all thresholds (and related metrics) for a test run.
GET https://api.k6.io/loadtests/v2/thresholds?test_run_id={test_run_id}&ids[]={threshold_id_1}
Read threshold
Returns details of a threshold with the specified ID.
GET https://api.k6.io/loadtests/v2/thresholds/{id}?test_run_id={test_run_id}
{
"k6-threshold": {
"calc_state": {
"max_created_at": "2020-08-18 13:36:41.348933+00:00",
"max_time": "2020-08-18 13:36:04+00:00",
"min_time": "2020-08-18 13:34:05+00:00",
"tainted_value": null
},
"calculated_value": 22024.0,
"id": 166100,
"metric_id": "threshold_166100",
"name": "threshold_1",
"stat": "count",
"tainted": false,
"tainted_at": null,
"test_run_id": 0,
"value": 200.0
}
}
Read test run overview
Returns an overview of the test run which includes numbers of URLs, thresholds, checks, etc.
GET https://api.k6.io/loadtests/v2/run-overviews?test_run_id={test_run_id}
{
"k6-run-overviews": [
{
"checks_hits_successes": 44048,
"checks_hits_total": 44048,
"checks_successes": 2,
"checks_total": 2,
"http_req_duration_avg": 21.3739818525472,
"http_reqs_avg": 716.2276422764228,
"test_run_id": 0,
"thresholds_successes": 2,
"thresholds_total": 3,
"urls_hits_successes": 88096,
"urls_hits_total": 88096,
"urls_successes": 4,
"urls_total": 4
}
]
}
Export test run metrics
Exports metric data for test run in CSV format.
The file URL is in the export.export_file
field of List test runs response.
POST https://api.k6.io/loadtests/v2/runs/{test_run_id}/export
{
"exports": [
{
"export_status": 1,
"load_test_run_id": 0
}
]
}