Help Center> IoT Device Access> Best Practices> Data Forwarding> Forwarding Device Data to OBS for Long-Term Storage

Forwarding Device Data to OBS for Long-Term Storage

Scenarios

If you want to store data reported by devices for a long term, you can either forward the data to application servers or to Object Storage Service (OBS) for storage.

In this example, data reported by all devices is forwarded to OBS.

Creating an OBS Bucket

  1. Log in to HUAWEI CLOUD and visit OBS.
  2. Click Access Console to go to the OBS console.
  3. Click Create Bucket in the upper right corner of the page, select bucket specifications as required, and click Create Now.

Configuring IoT Device Access

Using IoT Device Access, you can create a product model, register a device, and set a data forwarding rule to forward data reported by the device to OBS.

  1. Log in to the IoTDA console.
  2. On the navigation pane, click Products. Click the drop-down list box above the product list, and select the resource space to which the new product belongs.

    Note: The product model and device used in this document are only examples. You can use your own product model and device.

  3. Click Create Product in the upper right corner to create a product using MQTT. Set the parameters and click Create.

    Basic Information

    Product Name

    Enter a value, for example, MQTT_Device.

    Protocol Type

    Select MQTT.

    Data Type

    Select JSON.

    Manufacturer Name

    Customize the value.

    Define Product Model

    Product Model

    Import a product model by referring to 5.

    Industry

    Set the parameters as required.

    Device Type

  4. Click Profile.zip to download a sample product model.
  5. On the Model Definition tab page, click Import Local Profile. In the dialog box displayed, upload the product model and click OK.

  6. In the navigation pane, choose Devices > All Devices. On the page displayed, click Individual Register in the upper right corner. On the page displayed, set device registration parameters and click OK.

    Parameter

    Description

    Product

    Select the product created in 3.

    Node ID

    Specify a unique physical identifier for the device, such as its IMEI or MAC address. This parameter is used by the platform to authenticate the device during device access.

    • For a native MQTT device, set the node ID to a string consisting of letters and numbers. The device ID (corresponding to the node ID) and secret generated after the registration are used for device access.
    • For an NB-IoT device or a device integrated with the SDK, set the node ID to the IMEI or MAC address. The device connects to the platform using the node ID and secret entered during registration.

    Device Name

    Customize the value.

    Authentication Type

    Select Secret.

    Secret

    Customize the secret used for device access. If the secret is left blank, the platform automatically generates a secret.

    Click OK. Save the device ID and secret returned after the registration is successful.

  7. In the navigation pane, choose Rules > Data Forwarding, and click Create Rule in the upper right corner.
  8. Set the parameters based on the table below. The following parameter values are only examples. You can create your own rules by referring to User Guide. After setting the parameters, click Create Rule.

    Parameter

    Description

    Rule name

    Customize a name, for example, iotda-obs.

    Description

    Enter a rule description, for example, forwarding data to OBS for storage.

    Data Source

    Select Device property.

    Trigger

    Device property reported is automatically populated.

    Resource Space

    Select the resource space specified in 2.

    Quick Configuration

    1. Click Quick Configuration on the right.
    2. Select Data that meets the following conditions.
    3. Product: Select the product created in 3.
    4. Do not configure Service and Filtering by Property. Click OK.
  9. Click the Set Forwarding Target tab, and then click Add to set a forwarding target.

    Parameter

    Description

    Forwarding Target

    Select Object Storage Service (OBS).

    Region

    Select the region where OBS is located. If IoTDA is not authorized to access the service in this region, configure cloud service access authorization as prompted.

    OBS Bucket

    Select the bucket where data is to be stored. If no OBS bucket is available, create one on the OBS console.

  10. Click Enable Rule to activate the configured data forwarding rule.

Verifying the Configurations

  • You can use a registered physical device to access the platform and enable the device to report data.
  • You can also use a simulator to simulate a device to report data. For details, see Connecting MQTT Devices.

Expected result:

Log in to the OBS console, and click the bucket name. On the Objects page, you can view the data reported by the device.

You can also use the APIs provided by OBS to read files.