Manage metrics
This topic describes the metrics feature of the IoT Platform Data Service. Using data from devices in a workshop, you can manage and derive metrics for data visualization and analysis to uncover insights and improve production efficiency.
Prerequisites
Data backup must be enabled for the relevant products. For more information, see Back up device data sources.
Background
Time-series data collected from devices requires processing and calculation. For example, you may need to calculate the max temperature in the last 1 day, min temperature in the last 1 day, and average temperature in the last 1 day. This helps you analyze daily temperature changes and identify opportunities for production improvement.
Step 1: Import raw definition metrics
-
Log on to the IoT Platform console. On the Instance Overview tab, find and click your instance.
-
In the left-side navigation pane, select Data Service > Data Metric, and single click Customize Metric.
-
On the Custom Metrics tab, click Product Angle of View.
-
In the product list, select the checkboxes next to Temperature and Humidity Sensor and Power Meter, and then click Import at the bottom of the list.
-
In the Import Raw Definition Metrics panel, select all raw definition properties and click Import.
The panel displays a list of properties for the selected products. By default, the Also add atomic words checkbox is selected.
Step 2: Add atomic words
In the previous step, you added the atomic words defined in the product's thing model. Add the following three atomic words: Max Temperature, Min Temperature, and Avg Temperature.
-
In the left-side navigation pane, select Data Service > Data Metric, and single click Customize Metric.
-
At the top right of the data list, on the Customize Metric tab, single click Lexicon Management.
-
On the Atomic Words tab, click Add Atomic Word.
-
On the Add Atomic Word page, configure the parameters for Max Temperature and click Complete.
For more information about the parameters, see Add an atomic word. In this example, set Metric Scope to Product, set Display Name to Max Temperature, set Identifier to max_temperature, set Unit of Measure to Count/Celsius (°C), and set Value Range to -50~50.
-
Repeat the preceding steps to add the Min Temperature and Avg Temperature atomic words.
Step 3: Add a metric
Configure the corresponding derived metrics for the new atomic words and publish them for data analysis.
For more information, see Add a metric.
-
In the left-side navigation pane, select Data Service > Data Metric, and single click Customize Metric.
-
Navigate to the All Metrics tab and single click Create a Metric.
-
On the Add Metric page, configure the following parameters.
Select Temperature and Humidity Sensor as the entity for the metric. For Derivation Scope, select sub-entity to use data from the devices under the product.
-
Configure the metric definition parameters.
For Time Modifier, select Last 1 Day. For Atomic Word, select Max Temperature. The metric name Max temperature in the last 1 day is automatically generated. Set Processing Method to Derived from existing metric assets, select Yes for Calculable, and set Statistical Frequency to Daily. In the Define Calculation Rule section, set Calculation Method to aggregation, choose MAX (Maximum) as the aggregation function, and select Temperature as the data source.
-
Click Complete and Go Online.
-
Repeat the preceding steps to configure the Min temperature in the last 1 day and Avg temperature in the last 1 day metrics.
-
Min temperature in the last 1 day
Use the same configuration as the max temperature metric, but select Min Temperature for Atomic Word, and in the Calculation Rule, set the aggregation function to MIN (Minimum).
-
Avg temperature in the last 1 day
Use the same configuration as the max temperature metric, but select Avg Temperature for Atomic Word, and in the Calculation Rule, set the aggregation function to AVG (Average).
-
You can view the new metrics on the All Metrics tab under Data Service > Metrics > Custom Metrics.
Step 4: Backfill a metric
Derived metrics are based on backed-up data, which is stored on a T+1 schedule. If you need to backfill historical data, you must create a backfill task manually.
-
In the left-side navigation pane, select Data Service > Data Metric, and single click Customize Metric.
-
Navigate to the Customize Metric tab and single click the Metric Task in the upper right corner.
-
Select the Retrieval Instance tab, then single click Create Retrieval Task.
-
In the Create Backfill Task panel, configure the parameters and click Confirm.
For more information about the parameters, see Metric backfill.
Set the start and end dates under Select Backfill Dates, select the Backfill Downstream Metrics checkbox, and choose the metrics to backfill, such as Max temperature in the last 1 day.
-
Repeat the preceding steps to create backfill tasks for the Min temperature in the last 1 day and Avg temperature in the last 1 day metrics.
After the backfill tasks are complete, the status changes to Succeeded, indicating that the aggregation is complete.