You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| expected_response <sup>(≥ v0.31)</sup> | By default, response statuses between 200 and 399 are `true`. Change the default behavior with [setResponseCallback](/javascript-api/k6-http/setresponsecallback-callback). |
71
+
| group | When the request runs inside a [group](/javascript-api/k6/group-name-fn), the tag value is the group name. Default is empty. |
| scenario | When the request runs inside a [scenario](/using-k6/scenarios), the tag value is the scenario name. Default is empty. |
72
75
| status | response status |
73
76
| url | defaults to URL requested |
74
77
@@ -84,9 +87,11 @@ Below you can see how a test result data point (the duration of an HTTP request)
84
87
"time": "2017-06-02T23:10:29.52444541+02:00",
85
88
"value": 586.831127,
86
89
"tags": {
90
+
"expected_response": "true",
87
91
"group": "",
88
92
"method": "GET",
89
93
"name": "http://test.k6.io",
94
+
"scenario": "",
90
95
"status": "200",
91
96
"url": "http://test.k6.io"
92
97
}
@@ -144,7 +149,6 @@ Which would produce JSON output like the following:
144
149
"time":"2017-06-02T23:10:29.52444541+02:00",
145
150
"value":586.831127,
146
151
"tags": {
147
-
"group":"",
148
152
"method":"GET",
149
153
"name":"PostsItemURL",
150
154
"status":"200",
@@ -162,7 +166,6 @@ Which would produce JSON output like the following:
162
166
"time":"2017-06-02T23:10:29.58582529+02:00",
163
167
"value":580.839273,
164
168
"tags": {
165
-
"group":"",
166
169
"method":"GET",
167
170
"name":"PostsItemURL",
168
171
"status":"200",
@@ -176,7 +179,7 @@ Which would produce JSON output like the following:
176
179
177
180
Note how the `name` is the same for the two data samples related to two different URLs. Filtering the results on tag `name: PostsItemURL` will give you a result set including all the data points from all the 100 different URLs.
178
181
179
-
Additionally, you can use the `http.url`(v0.16.0) wrapper to set the name tag with a string template value:
182
+
Additionally, you can use the `http.url` wrapper to set the name tag with a string template value:
180
183
181
184
<CodeGroup labels={[]} lineNumbers={[true]}>
182
185
Collapse file: src/data/markdown/docs/01 guides/02 Using k6/02 Metrics.md
|`vus`| Gauge | Current number of active virtual users |
21
-
|`vus_max`| Gauge | Max possible number of virtual users (VU resources are pre-allocated, to ensure performance will not be affected when scaling up the load level) |
22
-
|`iterations`| Counter | The aggregate number of times the VUs in the test have executed the JS script (the `default` function). |
23
-
|`iteration_duration`| Trend | The time it took to complete one full iteration of the default/main function. |
24
-
|`dropped_iterations`| Counter | Introduced in k6 v0.27.0, the number of iterations that could not be started due to lack of VUs (for the arrival-rate executors) or lack of time (due to expired maxDuration in the iteration-based executors). |
25
-
|`data_received`| Counter | The amount of received data. Read [this example](/examples/track-transmitted-data-per-url) to track data for an individual URL. |
26
-
|`data_sent`| Counter | The amount of data sent. Read [this example](/examples/track-transmitted-data-per-url) to track data for an individual URL. |
27
-
|`checks`| Rate | The rate of successful checks. |
20
+
| vus | Gauge | Current number of active virtual users |
21
+
| vus_max | Gauge | Max possible number of virtual users (VU resources are pre-allocated, to ensure performance will not be affected when scaling up the load level) |
22
+
| iterations | Counter | The aggregate number of times the VUs in the test have executed the JS script (the `default` function). |
23
+
| iteration_duration | Trend | The time it took to complete one full iteration of the default/main function. |
24
+
| dropped_iterations | Counter | Introduced in k6 v0.27.0, the number of iterations that could not be started due to lack of VUs (for the arrival-rate executors) or lack of time (due to expired maxDuration in the iteration-based executors). |
25
+
| data_received | Counter | The amount of received data. Read [this example](/examples/track-transmitted-data-per-url) to track data for an individual URL. |
26
+
| data_sent | Counter | The amount of data sent. Read [this example](/examples/track-transmitted-data-per-url) to track data for an individual URL. |
27
+
| checks | Rate | The rate of successful checks. |
28
28
29
29
## HTTP-specific built-in metrics
30
30
31
31
_built-in_ metrics will only be generated when/if HTTP requests are made:
|`http_reqs`| Counter | How many HTTP requests has k6 generated, in total. |
36
-
|`http_req_blocked`| Trend | Time spent blocked (waiting for a free TCP connection slot) before initiating the request. `float`|
37
-
|`http_req_connecting`| Trend | Time spent establishing TCP connection to the remote host. `float`|
38
-
|`http_req_tls_handshaking`| Trend | Time spent handshaking TLS session with remote host |
39
-
|`http_req_sending`| Trend | Time spent sending data to the remote host. `float`|
40
-
|`http_req_waiting`| Trend | Time spent waiting for response from remote host (a.k.a. \"time to first byte\", or \"TTFB\"). `float`|
41
-
|`http_req_receiving`| Trend | Time spent receiving response data from the remote host. `float`|
42
-
|`http_req_duration`| Trend | Total time for the request. It's equal to `http_req_sending + http_req_waiting + http_req_receiving` (i.e. how long did the remote server take to process the request and respond, without the initial DNS lookup/connection times). `float`|
35
+
| http_reqs | Counter | How many HTTP requests has k6 generated, in total. |
36
+
| http_req_blocked | Trend | Time spent blocked (waiting for a free TCP connection slot) before initiating the request. `float`|
37
+
| http_req_connecting | Trend | Time spent establishing TCP connection to the remote host. `float`|
38
+
| http_req_tls_handshaking | Trend | Time spent handshaking TLS session with remote host |
39
+
| http_req_sending | Trend | Time spent sending data to the remote host. `float`|
40
+
| http_req_waiting | Trend | Time spent waiting for response from remote host (a.k.a. \"time to first byte\", or \"TTFB\"). `float`|
41
+
| http_req_receiving | Trend | Time spent receiving response data from the remote host. `float`|
42
+
| http_req_duration | Trend | Total time for the request. It's equal to `http_req_sending + http_req_waiting + http_req_receiving` (i.e. how long did the remote server take to process the request and respond, without the initial DNS lookup/connection times). `float`|
43
+
| http_req_failed <sup>(≥ v0.31)</sup> | Rate | The rate of failed requests according to [setResponseCallback](/javascript-api/k6-http/setresponsecallback-callback). |
43
44
44
45
### Accessing HTTP timings from a script
45
46
@@ -61,17 +62,17 @@ In the above snippet, `res` is an [HTTP Response](/javascript-api/k6-http/respon
Copy file name to clipboardExpand all lines: src/data/markdown/docs/01 guides/02 Using k6/04 Thresholds.md
+42-21Lines changed: 42 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: 'Thresholds'
3
-
excerpt: ''
3
+
excerpt: 'Thresholds are a pass/fail criteria used to specify the performance expectations of the system under test.'
4
4
---
5
5
6
6
## What are thresholds?
@@ -9,56 +9,55 @@ Thresholds are a pass/fail criteria used to specify the performance expectations
9
9
10
10
Example expectations (Thresholds):
11
11
12
-
- System doesn't produce more than 1% errors
12
+
- System doesn't produce more than 1% errors.
13
13
- Response time for 95% of requests should be below 200ms.
14
14
- Response time for 99% of requests should be below 400ms.
15
15
- Specific endpoint must always respond within 300ms.
16
+
- Any conditions on any [Custom metric](/using-k6/metrics#custom-metrics).
16
17
17
18
Thresholds analyze the performance metrics and determine the final test result (pass/fail).
18
19
Thresholds are a essential for [load-testing automation](/testing-guides/automated-performance-testing).
19
20
20
-
Here is a sample script that specifies two thresholds, one using a custom [Rate metric](/javascript-api/k6-metrics/rate), and one using a standard `http_req_duration` metric.
21
+
Here is a sample script that specifies two thresholds, one evaluating the rate of http errors (`http_req_failed` metric) and one using the 95 percentile of all the response durations (the `http_req_duration` metric).
- In the above case, the criteria for both thresholds were met. The whole load test is considered
57
57
to be a `pass`, which means that k6 will exit with exit code zero.
58
58
59
-
- If any of the thresholds had failed, the little green checkmark
60
-
<spanstyle="color:green; font-weight:bold">✓</span> next to the threshold name
61
-
(`failed requests`, `http_req_duration`) would have been a red cross <spanstyle="color:red; font-weight:bold">✗</span> instead, and k6 would have generated a non-zero exit code.
59
+
- If any of the thresholds had failed, the little green checkmark <span style="color:green; font-weight:bold">✓</span> next to the threshold name
60
+
(`http_req_failed`, `http_req_duration`) would have been a red cross <span style="color:red; font-weight:bold">✗</span> instead, and k6 would have generated a non-zero exit code.
62
61
63
62
## Copy-paste Threshold examples
64
63
@@ -80,7 +79,29 @@ export let options = {
80
79
};
81
80
82
81
export default function() {
83
-
let res1 =http.get('https://test-api.k6.io/public/crocodiles/1/');
0 commit comments