Create a Metric

更新时间:
复制 MD 格式

Configure derived metrics by combining time modifiers, atomic terms, and calculation logic. You can then use these metrics for further derivation, data analysis reports, and other tasks.

Prerequisites

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, go to the Overview page and click the ID or alias of the target Enterprise Edition instance.

  2. In the left-side navigation pane, select Data Service > Data Metric and 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

      The current entity.

      Sub-entity

      A sub-entity of the current entity. For derived definition metrics, you must select a sub-entity.

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

    2. Use the following guidelines to define the metric.

      Parameter

      Remarks

      Time Modifier

      Select 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

      Select the unit type and unit.

      Data Type

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

      Click the help

      Processing Method

      Derived from existing metric assets. This value cannot be modified.

      Is Calculable

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

      Statistical Frequency

      Data is processed and generated daily. This value cannot be modified.

      Expiration Date

      Set the expiration date for the metric.

      Important

      After the metric expires, data production scheduling stops.

      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

      Select 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

      Enter the operation expression in the input box. For supported functions, see 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

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

    Edit

    Modify the configuration of the derived metric.

    Unpublish

    Revert the metric to unpublished status. Related derived metrics and services will fail.

    Publish

    Make the metric publicly available.

    Clone

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

    Important

    Metrics with identical configurations to the original cannot be saved.

    Delete

    Remove the metric from the system.

    Important

    Deleting a metric fails under the following conditions:

    • The metric has associated downstream metrics.

    • The metric is in use within data analysis reports.

What to do next

Derived metrics represent T+1 day statistical data. To view data immediately after adding new metrics, manually initiate a refresh task.

For detailed instructions, see Metric Refresh.

Appendix: Function List

Function

Remarks

GREATEST

Returns the highest value among the given parameters.

LEAST

Returns the smallest value from the input parameters.

AVG

Returns the average of the specified parameters.

MAX

Determines the maximum value among the inputs.

MIN

Calculates the minimum value from the provided inputs.

SUM

Returns the sum of all input values.

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