Stand with Ukraine flag
Pricing Try it now
Trendz Analytics
Documentation > Metric exploration > Use New Metrics in ThingsBoard
Getting Started
Guides Installation
On this page

Use New Metrics in ThingsBoard

All metrics created with Metric Explorer can be integrated into ThingsBoard. They can be used wherever telemetry is supported:

  • Visualizations
  • Rule Engine
  • Alarm Profiles

Trendz allows you to automatically save metrics as telemetry to ThingsBoard or generate metrics from historical data and store them as telemetry. In this guide, we explore how to configure automatic saving of metrics to ThingsBoard and how to use this telemetry in ThingsBoard.

Save to ThingsBoard

Setting up saving a metric to ThingsBoard is divided into 3 parts:

  • Create a calculation field: an entity that supports telemetry save to ThingsBoard.
  • Run a reprocess task to process historical data.
  • Run a refresh task to automatically update telemetry.

Create Calculation Field

You can create a calculation field from a metric by clicking Save Calculation.

Specify the following parameters:

  1. Calculation Name – the name displayed in Trendz.
  2. Calculation Key – the telemetry key used in ThingsBoard (prefixed with _ECD_).

Example:

If you save a calculation named Energy Consumption Rate with the key energy_consumption_rate:

  1. Trendz will show a new field called Energy Consumption Rate.
  2. Telemetry will be saved in ThingsBoard with the key _ECD_energy_consumption_rate (once refresh and reprocess jobs are configured).

Then click Save — after that, the calculation field appears in the Calculation folder.

Before saving telemetry to ThingsBoard, verify the following parameters:

  1. Grouping Interval – defines how data is aggregated (e.g., HOUR means one point per hour in ThingsBoard).
  2. Aggregation – specifies how multiple values in the same interval are combined (e.g., SUM aggregates values within the same hour).
  3. Time – defines the time range used by refresh jobs (e.g., Last 7 Days for daily updates).

Recommended time settings:

  • Today – for minute or hourly jobs.
  • Last 7 Days – for daily jobs.
  • Last 14 Days – for weekly jobs.
  • Last 3 Months – for monthly jobs.

You can also adjust additional parameters as needed. Read more about the calculation field interface here.

Click Save Field and confirm saving by clicking the Save button to apply changes.
You will be prompted to enable the calculation field (run refresh task). You can do it right away or later.
The process of running the refresh task is described in another article.

Run Reprocess Task

Once the calculation field is created and all parameters are set up, you can run a Reprocess Job to save historical data to ThingsBoard.

Steps:

  1. Open the Tasks tab.
  2. Click Run Reprocess Task button.
  3. Select a time range for reprocessing.
  4. Choose items to run the job on (you can apply the same calculation to all entities with the same entity profile).
  5. Click Run button.

After completion, the telemetry will appear in ThingsBoard with the appropriate key.

Read more about reprocess task here.

Run Refresh Task

You can automate telemetry updates using a Refresh Job.

Steps:

  1. Click the Jobs button.
  2. Enable calculation result saving.
  3. Set the start date (from which data will be saved).
  4. Define the frequency (how often the job runs).
  5. Choose the target items (entities with the same entity profile) for automatic updates.
  6. Click Save button.

Once the refresh job is set up, you will see the Enabled status next to the calculation name.
From now on, telemetry will update automatically at the specified frequency for the selected items.

Read more about refresh task here.

Use in ThingsBoard

Once the calculation field, refresh job, and reprocess job are configured, the generated telemetry remains continuously updated in ThingsBoard.

You can now use the metric in ThingsBoard.

Automatic Alarm Creation

Since the telemetry exists in ThingsBoard, you can create alarms based on it:

  1. Open the entity profile where the calculation is created.
  2. Navigate to Alarm Rules and toggle Edit mode.
  3. Click Add alarm rule and set up create and clear alarm rules.
  4. Click Apply changes.

Example: You can create a metric that calculates deviations from the average temperature for sensors in a building.
If the deviation exceeds a threshold, an alarm will be triggered. This can detect device overheating or events such as a forgotten open window or broken refrigerator.

In this example, we created an alarm rule that triggers alarms when the absolute temperature deviation is greater than 10 and clears them when it is not. The alarm type is “Abnormal Temperature” and the severity is “Warning”.

Whenever the calculation refresh produces values that meet the alarm conditions, an alert will be triggered.

Trendz Visualizations

Visualize the generated metric using any Trendz widget, such as a line chart, heatmap, or state view (from the Range Analysis tab). You can also share the view with ThingsBoard.

Read about Trendz Visualizations here.

Read about how to share Trendz Views with ThingsBoard here.

Predict Future Values

You can use Trendz Prediction Models to forecast future values of the generated metric. You can then visualize them and share this view with ThingsBoard.

Learn more about prediction models here.

Detect Anomalies

You can detect anomalies or outages in the generated metric using Trendz Anomaly Models. If an anomaly is found, you can set up automatic alarm creation.

Learn more about anomaly detection here.

Next Steps