Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Documentationbreadcrumb arrow Grafana k6breadcrumb arrow JavaScript APIbreadcrumb arrow k6/x/mqttbreadcrumb arrow Clientbreadcrumb arrow Client.subscribe( topic, [options] )
Open source

Client.subscribe()

Subscribe to topics synchronously.

Signature

JavaScript
client.subscribe(topic, options)

Parameters

ParameterTypeDescription
topicstring | string[]Topic or array of topics to subscribe to
optionsobjectOptional subscription configuration
options.qosnumberQuality of Service level (0, 1, or 2). Default: 0
options.tagsobjectCustom tags for metrics (key-value pairs)