Menu
Scroll for more
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
Open source
Params
Params is an object used by the WebSocket constructor. The Params object contains request-specific options, such as headers that should be inserted into the connection initialization request.
| Name | Type | Description |
|---|---|---|
Params.compression | string | Compression algorithm to be used by the WebSocket connection. The only supported algorithm currently is deflate. |
Params.jar | http.CookieJar | The cookie jar that will be used when making the initial HTTP request to establish the WebSocket connection. If empty, the default VU cookie jar will be used. |
Params.headers | object | Custom HTTP headers in key-value pairs that will be added to the initial HTTP request to establish the WebSocket connection. Keys are header names and values are header values. |
Params.tags | object | Custom metric tags in key-value pairs where the keys are names of tags and the values are tag values. The WebSocket connection will generate metrics samples with these tags attached, allowing users to filter the results data or set thresholds on sub-metrics. |
Example of custom metadata headers and tags
A k6 script that makes a WebSocket request with a custom header and tags results data with a specific tag
JavaScript
JavaScript
import { WebSocket } from 'k6/websockets';
export default function () {
const url = 'ws://localhost:10000';
const params = {
headers: { 'X-MyHeader': 'k6test' },
tags: { k6test: 'yes' },
};
const ws = new WebSocket(url, null, params);
ws.onopen = () => {
console.log('WebSocket connection established!');
ws.close();
};
}The preceding example uses a WebSocket echo server, which you can run with the following command:
Bash
Bash
docker run --detach --rm --name ws-echo-server -p 10000:8080 jmalloc/echo-serverWas this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.