Cloud tests can export their metrics in near real-time to various APM platforms, allowing you to correlate and query testing metrics with other system metrics on your APM of choice:
Additionally, k6 Cloud supports exporting metrics to Prometheus instances using the remote write feature.
⭐️ Cloud APM integrations are available on Pro and Enterprise plans, as well as the annual Team plan and Trial.
Configuration
The APM export functionality is configured on the test level; each test has to set up its APM settings to export the metrics of their test runs.
- You can configure a test to export to multiple different APM providers.
- You can configure the APM settings using the k6 Cloud app and test builder or scripting the k6 test.
For more detailed instructions, refer to the documentation of your APM: Azure Monitor, DataDog, Grafana Cloud, or New Relic.
Default APM Metrics
By default, the APM integrations only export a subset of k6 metrics - the default APM metrics.
The includeDefaultMetrics option in the k6 script controls whether to export the default APM metrics or not. The default APM metrics are:
Metric Name | Type | Description |
---|---|---|
vus | Gauge | Current number of active virtual users |
iterations | Counter | The aggregate number of times the VUs in the test have executed the JS script. |
data_received | Counter | The amount of received data. |
data_sent | Counter | The amount of data sent. |
http_reqs | Counter | How many HTTP requests has k6 generated, in total. |
http_req_duration | Trend | Total time for the request. float |
If you are not familiar with the different types of k6 metrics, we recommend reading the Metrics page.
By default, the integration only send these metrics to avoid unexpected costs with your APM provider. APM providers charges based on the number of stored metrics, and a load test can generate a massive amount of metrics.
If you need to select the metrics to export, use the metrics option. In the k6 script, you can set both options - includeDefaultMetrics and metrics - as follows:
Considerations
- APM data export is supported for tests that are up to 1 hour long (3600 seconds plus 30 seconds of gracefulStop). Longer tests are currently not supported.
- If the APM configuration has errors, (e.g. invalid provider, wrong credentials, etc) the configuration will be ignored, and the test will be executed without the APM functionality.
- The data exported in near real-time may appear incorrect until the test is finished and the 2nd pass export has completed. The Prometheus Remote Write integration doesn't have a 2nd pass export.
- You cannot export metrics to two Prometheus Remote Write servers at the same time. This also applies to the other providers.