Exporting messages to Data Streams
Note
You can export data to Data Streams only from the */events and */commands topics.
-
In the management console
, select the folder where the registry is located. -
Select IoT Core.
-
Select the required registry from the list.
-
Navigate to the Export to Data Streams tab.
-
In the top-right corner, click Add export.
-
Fill out 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.writerrole.
-
Click Add.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To create an export:
-
Get a list of registries in the folder:
yc iot registry listResult:
+----------------------+-------------------+ | 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.writerrole.
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.