Menu
Grafana Cloud
Performance testing
Author and run tests
Cloud scripting extras
Cloud execution context variables
Grafana Cloud
Cloud execution context variables
When you run a cloud test, you can use three additional environment variables to find out in which load zone, server instance, and distribution label the script is currently running.
Name | Value | Description |
---|---|---|
K6_CLOUDRUN_LOAD_ZONE | string | The load zone from where the metric was collected. Values will be of the form: amazon:us:ashburn . |
K6_CLOUDRUN_INSTANCE_ID | number | A sequential number representing the unique ID of a load generator server taking part in the test, starts at 0. |
K6_CLOUDRUN_DISTRIBUTION | string | The value of the ext.loadimpact.distribution label" corresponding to the load generator instance. |
You can read the values of these variables in your k6 script as usual.
JavaScript
export const options = {
vus: 50,
duration: '30s',
ext: {
loadimpact: {
distribution: {
ashburnDistribution: { loadZone: 'amazon:us:ashburn', percent: 50 },
dublinDistribution: { loadZone: 'amazon:ie:dublin', percent: 50 },
},
},
},
};
export default function () {
if (__ENV.K6_CLOUDRUN_DISTRIBUTION === 'ashburnDistribution') {
// do something
} else if (__ENV.K6_CLOUDRUN_DISTRIBUTION == 'dublinDistribution') {
// do something
}
}
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:

Shift left performance testing with Grafana Cloud k6
This webinar covers how to automate testing and test earlier in the development process to bring high-quality products to market faster using k6 Cloud.

Kubernetes monitoring, out-of-the-box with Grafana Cloud
In this webinar you’ll learn how Grafana offers developers and SREs a simple and quick-to-value solution for monitoring their Kubernetes infrastructure.

Unify your data with Grafana plugins: Datadog, Splunk, MongoDB, and more
In this webinar, learn how to leverage Grafana's plugin ecosystem for access to 80+ data sources, including plugins for Datadog, Splunk, MongoDB, and more.