Exporting messages to Data Streams
Management console
CLI
API
-
In the management console
, select the folder where the registry is located. -
Select IoT Core.
-
Select the required registry from the list.
-
Go to the Export to Data Stream tab.
-
In the top-right corner, click Add export.
-
Fill in the fields as follows:
- Name: Export name.
- MQTT topic filter: Specify the topic from which you want to export messages or a filter using wildcard characters. If you leave this field empty, messages will be exported from all topics within the registry, including topics from all devices within the registry.
- Data stream: Specify the name of the data stream where you want to send messages from MQTT topics, or create a new one. If you chose to create a new stream, click Update to update the list of streams.
- Service account: Specify a service account with the
yds-writer
role.
-
Click Add.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To create an export:
-
Get a list of registries in the folder:
yc iot registry list
Result:
+----------------------+-------------------+ | ID | NAME | +----------------------+-------------------+ | arenou2oj4********** | my-registry | +----------------------+-------------------+
-
Create an export:
yc iot registry yds-export add \ --registry-name <registry_name> \ --name <export_name> \ --database <DB_path> \ --stream <stream_name> \ --mqtt-topic-filter <topic> \ --stream-service-account-name <service_account_name>
Where:
--registry-name
: Registry name.--name
: Export name.--database
: Location of the database storing the stream data, the second part of the Endpoint field value (following/?database=
), e.g.,/ru-central1/r1gra875baom********/g5n22e7ejf**********
.--stream
: Name of the data stream to receive messages from MQTT topics.--mqtt-topic-filter
: Topic to export messages from or filter using wildcard characters. If this parameter is not specified, messages will be exported from all topics within the registry, including topics from all devices within the registry.--stream-service-account-name
: Name of the service account with theyds-writer
role.
Result:
id: are520n46t********** name: export-from-topic registry_id: areqqa5ntm********** database: /ru-central1/b1gia87mbaom********/etnu4r0v1c********** stream: topic-message-stream service_account_id: ajeu9klp40********** created_at: "2023-09-18T09:52:28.840124837Z"
To add the export to Data Streams for a registry, use the RegistryService/AddDataStreamExport gRPC API call.