Skip to main content
k6 provides global __VU and __ITER variables for accessing VU and iteration information.

__VU

The __VU variable contains the current VU’s unique ID.
number
Current VU ID (1-based, unique within the test)

Usage

__ITER

The __ITER variable contains the current iteration number for the VU.
number
Current iteration number (0-based)

Usage

Environment Variables

__ENV

Access environment variables passed to k6.
Run with:

Examples

Per-VU Data Assignment

Iteration-based Pacing

Conditional Execution

Unique Session IDs

Comparison with exec

The global variables are simpler but less feature-rich than the k6/execution module:

When to use global variables:

  • Simple VU identification
  • Iteration counting
  • Quick prototyping

When to use k6/execution:

  • Need scenario information
  • Want to control test execution
  • Need to set tags/metadata
  • Require detailed execution state
The global variables __VU and __ITER are available in both the init and VU contexts, but they are only meaningful in the VU context.