All Products
Search
Document Center

IoT Platform:Create a Metric

Last Updated:Oct 31, 2024

This topic outlines how to configure derived metrics using time modifiers, atomic terms, and calculation logic, and how to utilize these metrics for further analysis, reporting, and other tasks.

Prerequisites

Ensure you have imported the original definition metrics and added atomic terms. For more information, see Import preset metrics and Add atomic words.

Procedure

  1. In the IoT Platform console, click Overview. On the Overview tab, find the instance that you want to manage and click the instance ID or the instance name.

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

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

  4. Follow the on-screen prompts to configure the metric definition.

    1. Select the domain for the new metric and proceed to choose the specific entity and Derivation Scope as guided by the prompts.

      Parameter

      Remarks

      This Entity

      Refers to the current entity in question.

      Sub-entity

      Targets sub-entities of the current entity. For derived definition metrics, sub-entities must be selected.

      For instance, if a product's sub-entity is its corresponding device, the derived definition metric would be computed for each device rather than the product as a whole.

    2. Use the following guidelines to define the metric.

      Parameter

      Remarks

      Time Modifier

      Choose a time modifier to define the statistical data range for the new metric.

      Atomic Term

      Select atomic terms previously added under the metric domain.

      To add atomic terms, single click the Go to Create Atomic Term button on the right. For more information, see Add atomic words.

      Metric Name

      The metric name is fixed and automatically combines the time modifier and atomic term.

      Example: Average Temperature of the Last 1 Day.

      Measurement Unit

      Choose the unit type and specific unit from the available options.

      Data Type

      Define the data type, precision, decimal places, and range of values.

      Click the help icon for detailed descriptions of data types.

      Processing Method

      Processing is derived from existing metric assets and cannot be modified.

      Is Calculable

      For accumulable numeric metrics like count, amount, or frequency, select Yes.

      Statistical Frequency

      Data is processed and generated on a daily basis, with no option for modification.

      Expiration Date

      Set the expiration date for the metric.

      Important

      Post-expiration, data production scheduling will cease.

      Metric Description

      Provide a business description for the metric, typically including the time modifier and atomic term.

      Example: Time Modifier: Last 1 Day, Atomic Term: Average Temperature

    3. Follow these instructions to establish the calculation rules.

      Calculation Method

      Remarks

      Example

      Aggregate Calculation

      Choose an aggregate function, metric, and operator from the dropdown menu. You can add up to 10 expressions.

      For example, select the sub-entity of the product domain, the function COUNT(Count), and the temperature of the product (od3****), indicating the calculation of the number of temperature records on the product (od3****) through derived definition metrics.

      Expression Calculation

      Input the operation expression in the provided box. For a list of supported functions, refer to the Appendix: Function List below.

      Click the Function button above the input box for instructions and examples.

      Expression syntax involves entering the aggregate function in the input box, inserting the $ or @ symbol within the function body, selecting the metric domain, adding a period (.), choosing the entity under the metric domain, then another period (.), and finally selecting the metric for derivation and calculation.

      The $ and @ symbols cater to different metric types:

      • $: Original definition and derived definition metrics.

      • @: Original and derived metrics.

      Note

      Basic operators are not supported within aggregate function expressions.

      For the product Temperature and Humidity Sensor with 100 devices, including the TH_sensor, the derived metric expression for Average Temperature of the Last Day based on the original metric and definition of Temperature is as follows:

      • avg($Product.Temperature and Humidity Sensor.Temperature): Calculates the average temperature across all devices on the product using derived definition metrics.

      • avg(@Device.TH_sensor.Temperature): Computes the average temperature for the TH_sensor device using derived definition metrics.

  5. Click Complete and Publish once.

    View the newly completed metrics in the All Metrics list.

    Note
    • Metrics that are selected with a single click on the Complete button will be marked as Unpublished and will not collect data.

    • Metrics that are incomplete can be sent to the draft box by single clicking Enter Draft Box, allowing for further editing and eventual completion of the publishing process.

  6. Optionally, in the All Metrics list, locate the desired metric, single click the function button in the operation column, and perform the following actions:

    Note

    Original definition metrics are limited to view and delete functions.

    Operation

    Remarks

    View

    Access basic information, calculation logic, data preview, and other metric details.

    Edit

    Adjust the configuration of the derived metric.

    Unpublish

    Revert the metric to unpublished status. This action will cause related derived metrics and services to fail.

    Publish

    Make the metric publicly available.

    Clone

    Duplicate the metric and modify its definition and settings as needed on the clone metric page to create a new metric.

    Important

    Metrics with identical configurations to the original cannot be saved.

    Delete

    Remove the metric from the system.

    Important

    Attempting to delete a metric under certain conditions will result in a failure:

    • The metric has associated downstream metrics.

    • The metric is in use within data analysis reports.

What to do next

As derived metrics represent T+1 day dimension statistical data, you may need to manually initiate a refresh task to view the data immediately after adding new metrics.

For detailed instructions, see Metric Refresh.

Appendix: Function List

Function

Remarks

GREATEST

Identifies the highest value among the given parameters.

LEAST

Returns the smallest value from the input parameters.

AVG

Computes the mean value of the specified parameters.

MAX

Determines the maximum value among the inputs.

MIN

Calculates the minimum value from the provided inputs.

SUM

Adds up all the input values to produce a sum.

COUNT

Counts the number of records that meet the specified criteria.

ABS

Computes the absolute value of a number.

CEIL

Rounds a number up to the nearest integer.

ROUND

Rounds a number to a specified number of decimal places.

TRUNC

Truncates a number to the designated number of decimal places without rounding.

COALESCE

Returns the first non-null value from a list of parameters.

[Pol