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
Copy file name to clipboardExpand all lines: docs/sources/next/using-k6/execution-context-variables.md
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,6 @@ The module provides test-execution information via three properties:
25
25
|[scenario](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#scenario)| The current running scenario |
26
26
|[vu](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#vu)| The current VU and iteration |
27
27
28
-
> k6 v0.34.0 introduced the **k6/execution** module.
29
-
> If you are using a version k6 that does not have this module,
30
-
> refer to the [\_\_VU and \_\_ITER](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/execution-context-variables#__vu-and-__iter-discouraged) section.
31
-
32
28
## Example: log all context variables
33
29
34
30
If you want to experiment with what each context variable looks like as a test runs,
@@ -81,29 +77,28 @@ VU tags: ${exec.vu.tags}`);
81
77
82
78
For detailed reference, refer to the [k6/execution module](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution).
83
79
84
-
## Examples and use cases
80
+
## Additional examples
85
81
86
82
-[Getting unique data once](https://grafana.com/docs/k6/<K6_VERSION>/examples/data-parameterization#retrieving-unique-data)
-[Executing different code blocks](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#script-naming)
89
85
90
86
{{< collapse title="_VU and _ITER (discouraged)" >}}
91
87
92
-
⚠️ **\_\_VU** and **\_\_ITER** are both global variables with execution-context information that k6 makes available to the test script.
88
+
{{< admonition type="note" >}}
93
89
94
-
### \_\_ITER
90
+
k6 v0.34.0 introduced the **k6/execution** module. If you are using a version of k6 that doesn't have this module, use `__VU` and `__ITER`.
95
91
96
-
A numeric counter with the current iteration number for a specific VU. Zero-based.
92
+
{{< /admonition >}}
97
93
98
-
### \_\_VU
94
+
`__VU` and `__ITER` are both global variables with execution-context information that k6 makes available to the test script.
99
95
100
-
Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one.
101
-
The variable is 0 when executing the setup and teardown functions.
96
+
-`__ITER`: A numeric counter with the current iteration number for a specific VU. Zero-based.
97
+
-`__VU`: Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one. The variable is 0 when executing the setup and teardown functions.
102
98
103
99
### Running in k6 Cloud
104
100
105
-
When you run tests in [k6 Cloud](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
106
-
Read the details in the [cloud docs](https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-ips/).
101
+
When you run tests in [Grafana Cloud k6](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
107
102
108
103
### Examples
109
104
@@ -136,7 +131,8 @@ export default function () {
136
131
137
132
{{< /collapse >}}
138
133
139
-
## Grafana Cloud k6 environment variables
134
+
## Grafana Cloud k6 context variables
135
+
136
+
Grafana Cloud k6 injects additional context variables into a running cloud test. These variables provide information about the server (`K6_CLOUDRUN_INSTANCE_ID`), load zone (`K6_CLOUDRUN_LOAD_ZONE`),instance ID (`K6_CLOUDRUN_INSTANCE_ID`), and cloud distribution (`K6_CLOUDRUN_DISTRIBUTION`).
140
137
141
-
If you run tests in k6 Cloud, you have additional environment variables that tell you the server, load zone, and distribution of the currently running test.
142
-
[Read about cloud environment variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-environment-variables/).
138
+
Refer to [Cloud execution context variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-execution-context-variables/) for more details.
Copy file name to clipboardExpand all lines: docs/sources/v0.52.x/using-k6/execution-context-variables.md
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,6 @@ The module provides test-execution information via three properties:
25
25
|[scenario](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#scenario)| The current running scenario |
26
26
|[vu](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#vu)| The current VU and iteration |
27
27
28
-
> k6 v0.34.0 introduced the **k6/execution** module.
29
-
> If you are using a version k6 that does not have this module,
30
-
> refer to the [\_\_VU and \_\_ITER](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/execution-context-variables#__vu-and-__iter-discouraged) section.
31
-
32
28
## Example: log all context variables
33
29
34
30
If you want to experiment with what each context variable looks like as a test runs,
@@ -81,29 +77,28 @@ VU tags: ${exec.vu.tags}`);
81
77
82
78
For detailed reference, refer to the [k6/execution module](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution).
83
79
84
-
## Examples and use cases
80
+
## Additional examples
85
81
86
82
-[Getting unique data once](https://grafana.com/docs/k6/<K6_VERSION>/examples/data-parameterization#retrieving-unique-data)
-[Executing different code blocks](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#script-naming)
89
85
90
86
{{< collapse title="_VU and _ITER (discouraged)" >}}
91
87
92
-
⚠️ **\_\_VU** and **\_\_ITER** are both global variables with execution-context information that k6 makes available to the test script.
88
+
{{< admonition type="note" >}}
93
89
94
-
### \_\_ITER
90
+
k6 v0.34.0 introduced the **k6/execution** module. If you are using a version of k6 that doesn't have this module, use `__VU` and `__ITER`.
95
91
96
-
A numeric counter with the current iteration number for a specific VU. Zero-based.
92
+
{{< /admonition >}}
97
93
98
-
### \_\_VU
94
+
`__VU` and `__ITER` are both global variables with execution-context information that k6 makes available to the test script.
99
95
100
-
Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one.
101
-
The variable is 0 when executing the setup and teardown functions.
96
+
-`__ITER`: A numeric counter with the current iteration number for a specific VU. Zero-based.
97
+
-`__VU`: Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one. The variable is 0 when executing the setup and teardown functions.
102
98
103
99
### Running in k6 Cloud
104
100
105
-
When you run tests in [k6 Cloud](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
106
-
Read the details in the [cloud docs](https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-ips/).
101
+
When you run tests in [Grafana Cloud k6](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
107
102
108
103
### Examples
109
104
@@ -136,7 +131,8 @@ export default function () {
136
131
137
132
{{< /collapse >}}
138
133
139
-
## Grafana Cloud k6 environment variables
134
+
## Grafana Cloud k6 context variables
135
+
136
+
Grafana Cloud k6 injects additional context variables into a running cloud test. These variables provide information about the server (`K6_CLOUDRUN_INSTANCE_ID`), load zone (`K6_CLOUDRUN_LOAD_ZONE`),instance ID (`K6_CLOUDRUN_INSTANCE_ID`), and cloud distribution (`K6_CLOUDRUN_DISTRIBUTION`).
140
137
141
-
If you run tests in k6 Cloud, you have additional environment variables that tell you the server, load zone, and distribution of the currently running test.
142
-
[Read about cloud environment variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-environment-variables/).
138
+
Refer to [Cloud execution context variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-execution-context-variables/) for more details.
0 commit comments