Before you start
- Assign access capabilities to create a hosted MQTT extractor and for the extractor to write data points, time series, events, RAW rows and in to data models in the target CDF project, depending on the resource types you want the extractor to ingest.
Deploy the extractor
1
Create a source
Create a Note that since this API is in beta, you will need to set the
Source by making a request to /api/v1/projects/{project}/hostedextractors/sources containing
just the external ID of the extractor you want to create. See the Source API specification.cdf-version header to beta in your request.2
Create a job
Create a Messages need to be transformed into a CDF resource, see Message formats below for details.
Job by making a request to /api/v1/projects/{project}/hostedextractors/jobs containing a destination external ID, the ID of the source you created in the previous step, and a config containing just topicFilter. This effectively subscribes to messages published by the user created in the previous step.3
Connect to the broker
This step is highly dependent on the client you wish to use to connect to the MQTT broker. Clients will allow you to specify a host, a username, and a password. Use the credentials provided in step 1.
Message formats
MQTT is a generic message transport protocol agnostic to the message payloads, which can be on any format. The Cognite MQTT broker supports several pre-defined message formats. If you want to define your own custom mapping of MQTT messages, see custom data formats for hosted extractors. Custom formats used with MQTT jobs will receive aninput argument containing the message as JSON, and a context argument containing the topic, for example:
+ denotes a single-level wildcard and matches any text between two slashes. For example, if you have several topics like these:
# denotes a multi-level wildcard and matches any text. It has to be used at the end of the topic filter. For example, if you have several topics like the following: