Generate Metrics¶
On the Metrics > Generate Metrics page, you can generate new metrics from existing data in the current workspace. You can also view the guaranteed streaming aggregations registered by dashboards and their sources in the Query Acceleration List.
Before You Begin¶
-
On the Generate Metrics tab, only roles with the "Generate Metrics Configuration Management permission" can create and edit metrics.
-
After metrics are generated, they are stored according to the current default data storage policy, and you are billed based on the number of generated time series.
-
If no data is reported after metrics are generated, the metrics cannot be queried or analyzed in the workspace.
What Problems Can It Solve for You?¶
Scenario 1: Extract business metrics from logs
Business logs contain key business data (such as order amounts and error codes) that needs to be converted into monitorable metrics. With Generate Metrics, you can select a log data source, configure query conditions to filter target logs, extract fields to generate metrics (such as error log count and average response time), and group by business dimensions (such as service, endpoint, and status code).
Scenario 2: APM data aggregation
Generate service SLA metrics based on APM trace data. Select an APM data source, group statistics by service and endpoint, calculate metrics such as P99 latency, error rate, and throughput, generate them on a schedule, and monitor continuously.
Scenario 3: Resource usage statistics
Collect statistics on Kubernetes cluster resource usage. Select a Basic Object or Resource Catalog data source, group by cluster, namespace, and node, collect statistics such as the number of Pods and resource requests/limits, and generate resource utilization metrics.
Scenario 4: Multi-source data fusion
Combine multiple data sources to generate composite metrics. Create generation rules separately, and generate new metrics based on the generated metrics to build a complex business monitoring system.
Applies To¶
Logs, APM, RUM, metrics, Synthetic Monitoring, Basic Objects, and Resource Catalog.
Create¶
- Select a data source.
- Configure data query conditions.
- Define the generated metrics content to set how metrics are generated and what the results contain, including the generation frequency, tag names of newly generated metrics, and measurement names.
Data Query¶
Metric data additionally supports PromQL queries. Other data types support simple queries and DQL queries.
For more details, refer to Chart Query.
Aggregate Functions¶
| Function | Description |
|---|---|
count |
Count the number of records |
avg |
Calculate the average value; you need to select the field to aggregate |
max |
Calculate the maximum value; you need to select the field to aggregate |
min |
Calculate the minimum value; you need to select the field to aggregate |
P75 |
Calculate the 75th percentile of the specified field; you need to select the field to aggregate |
P95 |
Calculate the 95th percentile of the specified field; you need to select the field to aggregate |
P99 |
Calculate the 99th percentile of the specified field; you need to select the field to aggregate |
Dimensions¶
Aggregate data by the selected objects, that is, generate one statistical value for each selected object in the data request.
Generated Metrics Content¶
-
Frequency: the execution interval for generating metrics. The time selected for frequency is also used as the aggregation time. If you select a frequency of 1 minute, metrics are aggregated and generated every 1 minute, and the time range of each aggregation is also 1 minute.
- 1 minute (default; that is, new metric data is generated once every 1 minute)
- 5 minutes (selected by default when the data type is "Basic Object" or "Resource Catalog")
-
Select a data wait window to specify how long the computation task waits after the task window ends.
-
Measurement: set the name of the measurement where metrics are stored.
-
Metrics: set metric names. Metric names can be duplicated, and you can add multiple metrics.
-
Tags: automatically generated based on the dimensions selected in the query.
-
Unit: optional. Set the unit of a metric. After a unit is set for a generated metric, it can be applied in chart queries.
-
Description: optional. Set the description of a metric. After a description is set for a generated metric, it can be applied in chart queries.
After completing the form, click OK to complete the Generate Metrics rule and start data collection.
Note
If data is delayed by more than 1 minute, it will not be counted after being stored in the database.
Data Wait Window¶
The duration for which the system continues to wait for data to arrive after the task window ends. When enabled, it accommodates data reporting delays and improves metric accuracy.
When generating metrics, the system executes queries on a schedule according to the frequency you set (for example, 1 minute). Each query searches a fixed time range (the "task window"). However, because there is a delay from data generation to reporting and storage, some data may arrive after the task window ends, so this "late" data cannot be counted.
After the data wait window is enabled, the system waits for an additional period after the task window ends, giving delayed data a chance to be included in the statistics, thereby improving metric accuracy.
1. The data wait window is recommended in the following scenarios:
| Scenario | Problem Description | Recommended Configuration |
|---|---|---|
| Long endpoint execution duration | An endpoint takes 70 seconds to execute. The span's time is the start time, but when it is stored, the next task window has already passed, so it is never counted. |
Data wait window ≥ maximum endpoint execution duration |
| Data reporting has network latency | Data takes an average of 10–30 seconds to travel from the client to the server. When querying data for the latest time, statistics are incomplete. | 1 minute |
| Batch reporting or network fluctuations | Some data is reported in batches or the network is unstable, and delays can reach several minutes. | 5 minutes or 15 minutes |
2. Calculation example (frequency 1 minute, data wait window 1 minute):
Task execution time: 13:01:00
Task window (actual time range queried): 13:00:00 ~ 13:01:00
Data wait window: 1 minute
Actual query execution time: 13:02:00 (after waiting for 1 minute)
That is, the system executes the query at 13:02:00 and searches for data whose time is between 13:00:00 and 13:01:00. At this point, even if some data is stored only after 13:01:00, as long as its time falls within 13:00:00–13:01:00, it can be counted.
Management List¶
-
Edit: View all created Generate Metrics rules and edit them.
-
Enable/Disable: Change the status of a rule. After a metric generation rule is disabled, the corresponding data will not be written to the measurement. Writing resumes after the rule is enabled.
-
Delete: Delete unnecessary rules. After a rule is deleted, the measurement is not deleted, but data writing stops.
-
Batch Operations: Perform batch operations on specific rules, including enabling, disabling, deleting, and exporting rules.
-
Import: Import Generate Metrics data.
-
View Metrics
-
View in Metrics Analysis: Go to the Metrics Analysis page for querying and analysis.
-
View in Metrics Management: Go to the Metrics Management page to view metrics and tags, where you can edit metric units and descriptions.
-
Note
- Because the data type is determined by the data source and aggregation expression of the Generate Metrics rule, some configurations cannot be edited or modified.
- Generated metrics are created by aggregating data based on the frequency and query time range you select. If no data is reported within that time range, no metrics can be generated, and they cannot be queried or searched in metrics.
Query Acceleration List¶
Go to Metrics > Generate Metrics > Query Acceleration List to view the streaming aggregations that have been registered after guaranteed acceleration is enabled for dashboard queries, and their sources.
The list is deduplicated by the streaming aggregations actually registered. When a query contains variables, the actual query after variable resolution is displayed. When the same streaming aggregation has multiple sources, the corresponding dashboards and charts are displayed together.
For how to enable or disable guaranteed acceleration, refer to Guaranteed Streaming Aggregation Acceleration.
The list displays streaming aggregation, source, registration time, and last hit time, and supports searching and filtering by query statement, dashboard, or chart.
View Source Details¶
Click a streaming aggregation in the list to view the following in the details pane on the right:
- The complete streaming aggregation query statement and registration information.
- Source dashboard, chart, and query template.
- When the query contains variables, the corresponding variable values.
Click a dashboard name to go to the corresponding dashboard. Viewing and navigation permissions follow the dashboard's permission settings.
Stop Guaranteed Acceleration¶
Guaranteed acceleration is controlled by the source dashboard and cannot be stopped directly in the Query Acceleration List. Click Stop Guaranteed Acceleration and follow the prompt to go to the source dashboard to turn off the option. If there are multiple sources, you need to turn it off in all source dashboards. After all sources are turned off, the corresponding record is automatically removed.
Use Cases¶
Chart Query¶
Query and analyze metric data in visualization charts.
Query Tool¶
Use DQL in Query Workbench to query and analyze metric data.

