---
title: "Use k6 extensions | Grafana Cloud documentation"
description: "Learn how to use k6 extensions in Grafana Cloud."
---

# Use k6 extensions

k6 has a set of core functionalities that you can use via its own set of JavaScript APIs. As a user, you might want to test a service or a protocol that’s not supported by the existing k6 APIs. That’s where extensions come in.

[k6 extensions](/docs/k6/latest/extensions/) are a way to extend the core functionality of k6. For k6 open source users, they can write custom extensions and then build a new k6 binary to use them locally. For Grafana Cloud k6 users, you can use a subset of these extensions when running your test scripts, without having to build a custom k6 binary.

## Supported extensions in Grafana Cloud

Grafana Cloud k6 has built-in support for two categories of extensions: Official and Community.

### Official extensions

These are extensions owned and maintained by Grafana Labs, with support for a wide range of versions.

Grafana guarantees regular maintenance, such as security patches and new versions that add or improve functionality.

| Extension                                                                     | Description                                                                                                                  | Versions                                       |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [xk6-dns](https://github.com/grafana/xk6-dns)                                 | DNS resolution and lookups in your tests                                                                                     | v1.0.1, v1.0.0                                 |
| [xk6-faker](https://github.com/grafana/xk6-faker)                             | Generate fake data in your tests                                                                                             | v0.4.4, v0.4.3, v0.4.2, v0.4.1, v0.4.0         |
| [xk6-icmp](https://github.com/grafana/xk6-icmp)                               | ICMP protocol support for k6                                                                                                 | v0.2.0, v0.1.0                                 |
| [xk6-mqtt](https://github.com/grafana/xk6-mqtt)                               | MQTT protocol support for k6                                                                                                 | v0.2.0, v0.1.1                                 |
| [xk6-redis](https://github.com/grafana/xk6-redis)                             | Extension for Redis database                                                                                                 | v0.3.6                                         |
| [xk6-sql](https://github.com/grafana/xk6-sql)                                 | Load-test SQL Servers                                                                                                        | v1.0.5, v1.0.4, v1.0.3, v1.0.2, v1.0.1, v1.0.0 |
| [xk6-sql-driver-mysql](https://github.com/grafana/xk6-sql-driver-mysql)       | xk6-sql driver extension for MySQL database support                                                                          | v0.2.1, v0.2.0, v0.1.0                         |
| [xk6-sql-driver-postgres](https://github.com/grafana/xk6-sql-driver-postgres) | xk6-sql driver extension for Postgres database support                                                                       | v0.1.1, v0.1.0                                 |
| [xk6-ssh](https://github.com/grafana/xk6-ssh)                                 | Use SSH connections in your tests                                                                                            | v0.1.3, v0.1.2, v0.1.1, v0.1.0                 |
| [xk6-tcp](https://github.com/grafana/xk6-tcp)                                 | TCP protocol support for k6                                                                                                  | v0.2.0                                         |
| [xk6-docs](https://github.com/grafana/xk6-docs)                               | CLI k6 docs for AI agents and users. It comes with an agent skill to help AI agents to write k6 scripts with best practices. | v0.0.8, v0.0.7, v0.0.6, v0.0.5, v0.0.1         |
| [xk6-subcommand-explore](https://github.com/grafana/xk6-subcommand-explore)   | Explore k6 extensions for Automatic Resolution                                                                               | v1.0.0                                         |

### Community extensions

These are extensions developed by the community, with support for specific versions.

Grafana doesn’t guarantee support for community extensions beyond allowing the use of vetted versions.

| Extension                                                                               | Description                                                                                                    | Versions         |
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------|
| [xk6-disruptor](https://github.com/grafana/xk6-disruptor)                               | Add fault injection capabilities to k6, following the chaos engineering principles.                            | v0.3.17          |
| [xk6-kafka](https://github.com/mostafa/xk6-kafka)                                       | Load test Apache Kafka. Includes support for Avro messages.                                                    | v1.0.0           |
| [xk6-kubernetes](https://github.com/grafana/xk6-kubernetes)                             | A k6 extension for interacting with Kubernetes clusters while testing.                                         | v0.10.3          |
| [xk6-loki](https://github.com/grafana/xk6-loki)                                         | Test Grafana Loki log ingestion endpoints                                                                      | v1.0.1, v1.0.0   |
| [xk6-msgpack](https://github.com/Tango-Tango/xk6-msgpack)                               | k6 MessagePack extension                                                                                       | v0.0.3           |
| [xk6-client-prometheus-remote](https://github.com/grafana/xk6-client-prometheus-remote) | Test Prometheus Remote Write-compatible endpoints                                                              | v0.3.2           |
| [xk6-sql-driver-azuresql](https://github.com/grafana/xk6-sql-driver-azuresql)           | xk6-sql driver extension for Microsoft Azure SQL database support                                              | v0.1.1, v0.1.0   |
| [xk6-sql-driver-clickhouse](https://github.com/grafana/xk6-sql-driver-clickhouse)       | xk6-sql driver extension for ClickHouse database support                                                       | v0.1.1, v0.1.0   |
| [xk6-sql-driver-sqlserver](https://github.com/grafana/xk6-sql-driver-sqlserver)         | xk6-sql driver extension for Microsoft SQL Server database support                                             | v0.1.1, v0.1.0   |
| [xk6-sse](https://github.com/phymbert/xk6-sse)                                          | Server Sent Event                                                                                              | v0.1.11, v0.1.10 |
| [xk6-tls](https://github.com/grafana/xk6-tls)                                           | TLS certificates validation and inspection                                                                     | v0.1.0           |
| [xk6-client-tracing](https://github.com/grafana/xk6-client-tracing)                     | This extension provides k6 with the required functionality required to load test distributed tracing backends. | v0.0.9           |
| [xk6-subcommand-httpbin](https://github.com/grafana/xk6-subcommand-httpbin)             | Run a local httpbin server from k6                                                                             | v1.0.0           |

## Use extensions in Grafana Cloud

There are different requirements for using extensions in Grafana Cloud depending on how you execute your test script.

### Before you begin

- Extensions are only supported when running your test scripts using the **Script editor** or the CLI.
- When running your tests via the CLI, [use k6](/docs/k6/latest/set-up/install-k6/) v1.2 or later, which includes native support for extension loading.
- Using extensions via the **Test builder** isn’t supported.

### Import an extension in your test script

The first step to using a cloud extension is to import it into your test script. For example, if you want to use the `xk6-faker` extension, you can add the following `import` statement:

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import faker from 'k6/x/faker';
```

You can then use any functionality available from the extension. For example, you can create a random name using the `faker.person` class:

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import faker from 'k6/x/faker';

export default function () {
  console.log(faker.person.firstName());
}
```

If you are interested in specifying the version of k6 or the extensions, refer to [Override versions](/docs/grafana-cloud/testing/k6/author-run/k6-versions/#override-k6-versions-and-extension-versions).

### Run a test with an extension in Grafana Cloud

To run a test script that uses an extension, you have to use the Script editor or the CLI.

#### Run a test via the script editor

The script editor supports built-in extensions by default. You can import and use any extensions, and run your test without any additional steps.

#### Run a test via the CLI

Make sure you have *k6 v1.2 or later* installed by running the following command:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
k6 version
```

Then, follow these steps to run your test script with extensions:

1. [Authenticate](/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication/#authenticate-with-the-login-command) with Grafana Cloud:
   
   Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```bash
   k6 cloud login --token <API_TOKEN> --stack <STACK_SLUG>
   ```
2. Run your test.
   
   - In the cloud:
     
     Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
     
     ```bash
     k6 cloud run test.js
     ```
   - Locally (with cloud-provisioned binary):
     
     Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
     
     ```bash
     k6 cloud run --local-execution test.js
     ```

If your script uses [supported extensions](/docs/grafana-cloud/testing/k6/author-run/use-k6-extensions/#supported-extensions-in-grafana-cloud), k6 automatically detects them and provisions a compatible binary, either in Grafana Cloud or locally.

##### Example output

text ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```text
INFO[0287] A new k6 binary has been provisioned with version(s): k6:v1.1.0 k6/x/faker:v0.4.4
```

## Disable extensions

You can disable this feature by setting the environment variable `K6_AUTO_EXTENSION_RESOLUTION` to `false`. If provided, the previous example fails because k6 can’t load the extension dynamically.

For example:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
K6_AUTO_EXTENSION_RESOLUTION=false k6 cloud run test.js
```

And an example output for a test failure:

text ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```text
ERRO[0000] GoError: unknown module: k6/x/faker           hint="script exception"
```
