Hopp til hovedinnhold

Cognite MQTT extractor

Beta

The features described in this section are currently in beta testing and are subject to change.

The Cognite MQTT extractor is a generic extractor that extracts data over the MQTT protocol, connects to an MQTT broker, and subscribes to data on one or more topics.

The MQTT extractor is hosted by Cognite, so you don't have to download and install anything. To deploy the extractor:

  1. Make sure the extractor has the following access capabilities in a Cognite Data Fusion (CDF) project: timeseries:READ, timeseries:WRITE for writing datapoints and time series, events:READ, events:WRITE, assets:READ for writing events, or raw:READ, raw:WRITE for writing raw rows.

    tips

    You can use OpenID Connect and your existing identity provider (IdP) framework to manage access to CDF data securely. For more information, see setup and administration for extractors.

  2. Navigate to the CDF portal application > Connect to source systems. 1. Locate the Cognite MQTT extractor and select Set up extractor.

About MQTT

MQTT is a generic message transport protocol agnostic to the message payloads, which can be on any format. The Cognite MQTT extractor supports a number of pre-defined message formats, and you can define your own.

Messages are published on topics. A topic can be any string of text, but usually it is a hierarchical structure, separated by forward slashes, for example:

company/location3/machine1/pressure

Clients can subscribe to messages by subscribing to topic filters. A topic filter can be a topic written verbatim, but it also allows for wildcards such that one subscription can yield data from multiple topics. MQTT supports single-level and multi-level wildcards.

A single-level wildcard is denoted by a + and matches any text between two slashes. For example, if you have several topics like these:

company/location3/machine1/pressure
company/location3/machine2/pressure
company/location3/machine3/pressure

You can subscribe to all of them by subscribing to this topic filter:

company/location3/+/pressure

A multi-level wildcard is denoted by a #, 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:

company/location3/machine1/pressure
company/location3/machine2/pressure
company/location3/machine1/temperature

You can subscribe to all of them by subscribing to this topic filter:

company/location3/#

Message formats

See Custom data formats for hosted extractors for how to write your own custom mapping of MQTT messages. Custom formats used with MQTT jobs will receive an input argument containing the message as JSON, and a context argument containing the topic, for example

{
"topic": "company/location3/machine/pressure"
}

The topic given in the context will be the actual topic the message arrived on, not the topic filter, so it can be used to distinguish identical messages arriving on different topics.