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.
Documentation
Grafana k6
JavaScript API
k6/x/mqtt
Client
Client.publishAsync( topic, payload, [options] )
Open source
Client.publishAsync()
Publish a message asynchronously. Returns a promise that resolves when the message is published.
Signature
JavaScript
await client.publishAsync(topic, payload, options)Parameters
| Parameter | Type | Description |
|---|---|---|
| topic | string | Topic to publish to |
| payload | string | ArrayBuffer | Message payload (string or binary data) |
| options | object | Optional publish configuration |
| options.qos | number | Quality of Service level (0, 1, or 2). Default: 0 |
| options.retain | boolean | Whether the message should be retained by the broker. Default: false |
| options.tags | object | Custom tags for metrics (key-value pairs) |
Returns
A promise that resolves when the message is successfully published.
Was 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.