Daily power consumption metrics

更新时间:
复制 MD 格式

This topic demonstrates how to use the data metric management feature of IoT Platform to calculate daily power consumption metrics, using a streetlight as an example.

Prerequisites

You have completed the following operations:

  1. You have purchased an Enterprise Edition instance. For more information, see Purchase an Enterprise Edition instance.

    This example requires the Cold Data Storage and Data Processing Unit specifications.

    Note

    You can also apply for a free trial of an Enterprise Edition instance of IoT Platform. The free trial instance includes the Cold Data Storage and Data Processing Unit specifications by default. For more information, see Free trial of Alibaba Cloud IoT Platform products.

  2. You have created a product and a device. For more information, see Create a product and Create a single device.

    This example uses a product named Streetlight and a device named device01. The product's standard category is Smart City/Public Service/Streetlight and its node type is direct-connected device.

  3. You have enabled device data backup for the current instance. For more information, see Back up device data sources.

    In this example, you have backed up data for devices under the Streetlight product.

  4. You have developed the device and it reports data. For development instructions, see Device-side development guide.

    Alternatively, you can use the device simulator to simulate a device reporting real-time data. For more information, see device simulator.

    In this example, the Streetlight product's device, device01, has uploaded real-time PowerConsumption data for the last 7 days.

Step 1: Create an atomic metric

  1. On the Instance Overview page of the IoT Platform console, click the ID or alias of the target Enterprise instance.

  2. In the left-side navigation pane, select Data Service > Data Metric, and single click Customize Metric.

  3. At the top right of the data list, on the Customize Metric tab, single click Lexicon Management.

  4. On the Atomic Metric tab, click Create Atomic Metric.

  5. Add an atomic metric named Power Consumption.

    For parameter descriptions, see Create an atomic metric.

    Configure the parameters: For Metric Scope, select device. For Identifier, enter PowerConsumption. For Unit of Measurement, select Kilowatt-hour (kW·h). For Data Type, select floating-point number (double). For Precision, enter 309. For Decimal Places, enter 1. For Value Range, enter 0 to 2147483647. For Business Scope, enter Power consumption; electrical parameters use 4-byte floating-point data.

  6. Click Complete.

Step 2: Create a metric

For detailed parameter descriptions, see Create a metric.

  1. Navigate to the All Metrics tab and single click Create a Metric.

  2. Configure the metric definition.

    1. Select device as the metric scope, and then select the specific entities: the Streetlight product and the device01 device.

      For Derivation Range, select Current entity to use the device's own data.

    2. Select a time qualifier and an atomic metric to complete the metric definition.

      The time qualifier determines the analysis time range, and the atomic metric determines the base metric. Configure other parameters as needed.

      In this example, for Time Qualifier, select Last 1 Day. For Atomic Metric, select PowerConsumption. The Expiration Date defaults to one year, meaning the aggregated daily power consumption data is retained for this period.

      In this example, set Statistical Frequency to Daily, Unit of Measurement to Kilowatt-hour (kW·h), Data Type to floating-point number (double), and Can be Calculated to Yes.

    3. Select a calculation method and define the calculation rule.

      In this example, the Streetlight power consumption is generated per minute, so you can use the SUM function to aggregate it.

      For Calculation Method, select aggregate calculation.

  3. Click Complete and Go-live.

After you publish the daily power consumption metric, it runs daily to calculate statistics.

If you want to view the metric immediately, you can run a metric backfill.

Step 3: Backfill the metric

You can run a metric backfill to view historical daily power consumption data for a specific time range.

  1. On the Customized Metric tab, click Metric Task in the upper-right corner.

  2. Click the Backfill Instance tab, and then click Create Backfill Task.

  3. In the Create Backfill Task panel, select the backfill dates and the metric to be backfilled.

    In this example, backfill the daily power consumption data from May 17, 2023, to May 23, 2023.

    Select Backfill Downstream Metrics. In the metric list, select the metric where Metric Name is Last 1 Day PowerConsumption, Metric Scope is device, and Associated Entity is device01.

  4. Click OK.

    After you create the metric backfill task, the Backfill Instances tab shows the task list and the backfill status.

    The task list includes the following columns: Metric Code, Metric Name, Associated Entity, Backfill Date, Submission Time - End Time, Status, and Actions. The initial status of a new backfill task is Initializing.

    You can click View in the Actions column for the backfill task to open the Backfill Details page, where you can select an execution record to view its logs.

  5. After the backfill instance succeeds, click the back icon image..png to the left of Metric Tasks to return to the Custom Metrics tab.

  6. Click View in the Actions column for the Last 1 Day PowerConsumption metric to preview the data.

    The metric details page displays the metric's metadata (such as Metric Status: Online, Metric Type: derived metric, Unit: kilowatt-hour, Metric Scope: device, and Associated Entity: device01), its calculation logic (Calculation Formula: SUM(@Device.device01.PowerConsumption), Date Dimension: Daily), and a line chart for data preview. The chart shows that the daily power consumption from May 17, 2023 to May 23, 2023 is approximately 2,000 kW·h, indicating that the data backfill was successful.

What to do next

  • Data reports: You can use data reports in IoT Platform to visualize the calculated metric data.

  • Data API: You can configure a Data API for cloud-to-cloud integration and communication.

Related documents

Data Metrics