Scenario: Ingesting Batch Data from Object Storage
Download sequential CSV objects from OCI Object Storage, transform each batch record in Node-RED, and ingest it into OCI IoT.
Use this scenario to download sequential CSV objects from Object Storage and replay offline or historical readings into OCI IoT so that digital twin history remains complete. The Node-RED flow is Inject -> Prepare Filename -> Object Storage Download -> Increment Index -> CSV -> Transform -> MQTT-OUT.
This scenario uses Object Storage because each CSV file is a discrete object that the flow downloads and processes on demand. If a flow instead needs shared files available through a mounted filesystem path, use File Storage. See Choosing File Storage or Object Storage.
Complete the common scenario setup before starting.
Tasks
Prerequisites
Create an Object Storage bucket for the batch CSV objects. Record the Object Storage namespace and bucket name. Create the Flow Runtime dynamic group, and ensure that the Resource Principal configuration used by the Object Storage node has the Object Storage read policy required to download objects from the bucket.
The Flow Runtime must be able to reach Object Storage and the OCI IoT device host.
Step 1: Creating the IoT Flow Runtime
Step 2: Uploading the Batch CSV Object
Choose an Import or Manual Configuration Path
If you already built this scenario manually, you do not need to import the JSON. Do not deploy both the imported and manually built copies; they can ingest duplicate readings.
Step 3: Importing this Scenario's JSON Flows file
The managed Node-RED editor opened from the OCI Console includes the OCI nodes required in this example.
The import creates a flow tab named Ingest Batch Data from Object Storage and its configuration nodes. It doesn't create the bucket, access policies, or digital twin resources required by the preceding steps and common setup. MQTT credentials aren't included in the exported JSON.
Step 4: Reviewing and Configuring the Node-RED Flow
If you imported the example, review and adjust the existing nodes using these steps. If you are building the flow manually, add and connect the nodes before configuring them.
Working with an Exported Complete Flows JSON file
To import the downloadable scenario, use Step 3: Importing this Scenario's JSON Flows file. For another exported flows document, use these editor steps. The CLI and API methods replace the runtime's complete flows document.
- Open the Flow Runtime editor. If you need help finding the editor, see Getting an IoT Flow Runtime's Details.
- In the Node-RED editor, open the main menu and select Import. For more details, see the Node-RED import documentation.
- Paste the exported flows document or select its file, and then select Import.
- Review the imported nodes and connections, and then select Deploy.
Use the
oci iot flow-runtime update-flowscommand to replace the complete flows document.oci iot flow-runtime update-flows \ --iot-flow-runtime-id <flow-runtime-ocid> \ --flows-document file://<path-to-flows-json>Note
The command replaces the complete flows document. Retrieve and save the current document first if you need a backup.For more information, see Updating Flows for an IoT Flow Runtime.
Run the UpdateIotFlowRuntimeFlows operation to replace the complete flows document.
PUT /20250531/iotFlowRuntimes/{iotFlowRuntimeId}/flows <complete-Node-RED-flows-document>Pass the exported complete Node-RED flows document as the request body. The synchronous operation returns the flows document and doesn't create a work request.
Note
This operation replaces the complete flows document. Retrieve and save the current document first if you need a backup.
Step 5: Deploying and Running the Flow
Step 6: Validating the Batch Data Ingestion
Troubleshooting
- Confirm the Object Storage namespace, bucket name, sequential object name, and Resource Principal configuration.
- Confirm that the Object Storage node uses Download output = Text and Encoding =
UTF-8. The CSV node receives text directly. - Review Object Storage errors in OS Node error catch and transformed messages in MQTT Input in the Debug sidebar. Re-enable the Debug nodes if you disabled them after validation.
- Confirm that
iot-data-<counter>.csvexists before the next poll. The counter advances only after a successful download. - Confirm that the CSV delimiter and first-row column names match the sample.
- Confirm that each row includes a supported
deviceType, a matching external key, and a numeric source timestamp. - Confirm the MQTT device-host connection, gateway credentials, adapter mappings, and target digital twin lifecycle states.
For more information, see Troubleshooting IoT Flow Runtimes.
FAQs
- Why do the CSV object names use a counter?
- The flow processes a predictable sequence such as
iot-data-1.csvandiot-data-2.csv. The counter advances only after a successful download so objects are processed in order. - Why does the Object Storage node use a Resource Principal?
- The Flow Runtime can access the approved bucket without storing user credentials in the flow. Its dynamic group and policy must grant the required read access.
- What happens when the next sequential object doesn't exist?
- The download fails and the counter remains unchanged. Upload the expected object or correct the namespace, bucket, prefix, and counter before triggering the flow again.
- Why does the Object Storage node download the object as text?
- The CSV node expects text input. Setting the download output to Text with UTF-8 encoding supplies that input directly; the index-increment Function only advances the counter and records the processed object name.
- How do I restart a test from the first CSV object?
- Disable the Inject node's repeat interval, then add a temporary Function node on the same flow tab with
flow.set("iotFileIndex", 1); return msg;. Connect a separate, manually triggered Inject node only to that Function node. Deploy and trigger it once to reset the counter, then remove both temporary nodes and deploy again. Trigger the scenario's Inject node to processiot-data-1.csvagain. This replays readings already ingested; use it only when you intend to repeat the test.