No results for

Powered byAlgolia

Execution context variables

In certain use cases information about the current test execution state inside your test scripts can be really useful.


The k6/execution module exposes various details about the current execution state, such as the name of the currently executed scenario or how many VUs are currently active and many more. The module provides test execution information via three properties:

instanceMeta information and execution details on the currently running k6 instance
scenarioMeta information and execution details about the current running scenario
vuMeta information and execution details about the current vu and iteration

k6 v0.34.0 introduced k6/execution module. If you are using an earlier version of k6, where the module is not available, refer to __VU and __ITER section.

Examples and use cases

_VU and _ITER (discouraged)

⚠️ __VU and __ITER are both global variables with execution context information that k6 makes available to the test script.


A numeric counter with the current iteration number for a specific VU. Zero-based.


Current VU number in use. The value is assigned incrementally for each new VU instance, starting from one. The variable will be 0 while executing the setup and teardown functions.

Running in the k6 Cloud

When you run your tests in the k6 Cloud, the __VU value you get will be per server/load generator. You can read the details in the cloud docs.


1import http from 'k6/http';
2import { sleep } from 'k6';
3export default function () {
4 http.get('');
5 console.log(`VU: ${__VU} - ITER: ${__ITER}`);
6 sleep(1);

Different test behaviors and parameterizations can be accomplished by making use of the execution context variables. A typical use case would be a load test simulating different users performing a login flow.

1import http from 'k6/http';
2import { sleep } from 'k6';
3export default function () {
4 const email = `user+${__VU}`;
5 const payload = JSON.stringify({ email: email, password: 'test' });
6 const params = { headers: { 'Content-Type': 'application/json' } };
7'', payload, params);
8 console.log(email);
9 // .. continue the user flow
10 sleep(1);

k6 Cloud environment variables

If you're running tests in k6 Cloud you will also have additional environment variables that will tell you on which server, load zone and distribution of the test you are currently executing. You can find more details and examples here.