Skip to content
Stand with Ukraine flag

Use Metrics in ThingsBoard

Metrics created in the Trendz Metric Explorer can be published to ThingsBoard as telemetry and used anywhere ThingsBoard supports telemetry — dashboards, Rule Engine, and Alarm Rules.

Generated Metric
│ Save Calculation
Native Calculation Field
├── Reprocess Task ──▶ Historical data saved to ThingsBoard
└── Refresh Task ────▶ Ongoing automatic updates
ThingsBoard Telemetry (key: _ECD_*)
┌───────────────┼───────────────┐
▼ ▼ ▼
Dashboards Alarm Rules Rule Engine

From the Generated Metric editor, click Save Calculation and enter:

ParameterDescription
Calculation NameLabel shown in Trendz for this field.
Calculation KeyTelemetry key used in ThingsBoard, automatically prefixed with _ECD_.

Example: saving key energy_consumption_rate creates ThingsBoard telemetry at _ECD_energy_consumption_rate.

Click Save — the field appears in the Calculation folder in the Fields Section.

Before running any jobs, verify the following parameters on the Calculation Field:

ParameterDescription
Grouping IntervalHow data is bucketed — e.g., HOUR saves one point per hour to ThingsBoard.
AggregationHow multiple values in the same interval are combined — e.g., SUM.
TimeThe lookback window used by the refresh job.

Recommended Time settings by job frequency:

Time settingUse when
TodayMinute or hourly jobs
Last 7 DaysDaily jobs
Last 14 DaysWeekly jobs
Last 3 MonthsMonthly jobs

Click Save Field, then confirm with Save to apply the parameters.

A Reprocess Task calculates the metric over a historical time range and saves the results to ThingsBoard. Run this once after creating the Calculation Field to populate historical data.

  1. Open the Tasks tab.

  2. Click Run Reprocess Task.

  3. Select the time range to reprocess.

  4. Choose the items — you can apply the job to the current item, all items, or a subset of items with the same entity profile.

  5. Click Run.

After the task completes, ThingsBoard will contain telemetry points for the selected period.

A Refresh Task keeps telemetry up to date by automatically recalculating the metric on a schedule.

  1. Click the Jobs button.

  2. Enable calculation result saving.

  3. Set the start date — the date from which new data will be saved.

  4. Define the frequency — how often the job runs.

  5. Choose the target items — entities with the same entity profile to update automatically.

  6. Click Save.

Once saved, the Enabled status appears next to the calculation name. Telemetry will now update automatically at the configured frequency for the selected items.

Once the Calculation Field is configured with a refresh job and historical data is loaded via a reprocess job, the metric telemetry is continuously updated in ThingsBoard. You can use it anywhere ThingsBoard supports telemetry — including dashboards, Alarm Rules, and the Rule Engine. The metric telemetry key (e.g., _ECD_energy_consumption_rate) is used in Rule Engine chains exactly like any other device telemetry key.

Create ThingsBoard alarms triggered by the metric telemetry:

  1. Open the entity profile where the calculation is applied.

  2. Navigate to Alarm Rules and enable Edit mode.

  3. Click Add alarm rule and configure the create and clear conditions.

  4. Click Apply changes.

Example: A metric calculates the absolute temperature deviation from the building average. An alarm rule triggers a Warning alarm of type Abnormal Temperature when the deviation exceeds 10, and clears it when it drops back below. This can detect device overheating, an open window, or a broken refrigerator — without writing any Rule Engine logic.

Visualize the metric using any Trendz widget — line chart, heatmap, state chart (from the Range Analysis tab), and more. Completed views can be embedded into ThingsBoard dashboards.

See Trendz Visualizations and Embed Visuals in ThingsBoard for details.

Use Trendz Prediction Models to forecast future values of the metric and embed the prediction view into a ThingsBoard dashboard.

See Prediction Models for details.

Use Trendz Anomaly Models to detect anomalies or outages in the metric. When an anomaly is detected, automatic alarm creation can be configured.

See Anomaly Detection for details.