tencent cloud

DescribeGeneralMetricData
Last updated:2026-02-04 10:28:28
DescribeGeneralMetricData
Last updated: 2026-02-04 10:28:28

1. API Description

Domain name for API request: apm.intl.tencentcloudapi.com.

This API is a general API used to obtain metric data. Users submit request parameters as needed and receive the corresponding metric data.
The API call frequency is limited to 20 requests per second and 1200 requests per minute. The number of data points per request is limited to 1440.
Usage of the General Interface for Fetching Metric Data
DescribeGeneralMetricData is a general interface for querying metric data, supporting flexible data retrieval. The query method of this interface is similar to using the following SQL statement:
SELECT {Metrics} FROM {ViewName} WHERE {Filters} GROUP BY {GroupBy}.

  1. View (ViewName)
    Determines the data domain you want to query.
    Examples: service_metric (Service Monitoring View), db_metric (Database View), etc. For views supported by APM, please refer to Metric Views
  2. Metrics (Metrics)
    Used to specify one or more metric items to be included in the returned results.
    Examples: request_count (Total Requests), duration_avg (Average Latency), error_rate (Error Rate). For metrics supported by APM, please refer to the APM Metric Protocol Standard.
  3. Filters (Filters)
    Supports one or more filtering conditions in the form of Key-Value pairs.
    Example: Querying only a specific service: service.name = "order-service". Common dimensions and specific dimensions supported by each ViewName can be used as keys in filtering conditions. For more details, please refer to the APM Metric Protocol Standard.
  4. Aggregation (GroupBy)
    Supports one or more aggregation dimensions, equivalent to the GROUP BY clause in SQL.
    Example: Grouping by the interface name operation to view the performance of each interface. Common dimensions and specific dimensions supported by each ViewName can be used as aggregation dimensions. For more details, please refer to the APM Metric Protocol Standard.
  5. Granularity (Period)
    This parameter determines whether the data needs to be aggregated by time slices.
    • Period = 1 (Time Series Mode): The returned results are aggregated by time slices. The multiple values contained in the TimeSerial and DataSerial correspond one-to-one, representing the aggregation results for specific time slices. Time Series Mode is primarily used for displaying time trend charts.
    • Period = 0 (Summary Statistics Mode): In the returned results, the DataSerial contains only a single value, representing the summarized data for the entire time range.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: DescribeGeneralMetricData.
Version Yes String Common Params. The value used for this API: 2021-06-22.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
Metrics.N Yes Array of String Metric name to be queried, which cannot be customized. (for details, see https://www.tencentcloud.com/document/product/248/101681?from_cn_redirect=1.).
InstanceId Yes String Business system id.
ViewName Yes String View name. the input cannot be customized. for details, see..
Filters.N Yes Array of GeneralFilter The dimension information to be filtered; different views have corresponding metric dimensions. (for details, see https://www.tencentcloud.com/document/product/248/101681?from_cn_redirect=1.).
GroupBy.N No Array of String Aggregated dimension; different views have corresponding metric dimensions. (for details, see https://www.tencentcloud.com/document/product/248/101681?from_cn_redirect=1.).
StartTime No Integer The timestamp of the start time, supporting the query of metric data within 30 days. (unit: seconds).
EndTime No Integer The timestamp of the end time, supporting the query of metric data within 30 days. (unit: seconds).
Period No Integer Whether to aggregate by a fixed time span: enter 1 for values of 1 and greater, and 0 if not filled in.
-If 0 is filled in, it calculates the metric data from the start time to the cutoff time.
- if 1 is filled in, the aggregation granularity will be selected according to the time span from the start time to the deadline:.
-If the time span is (0,12) hours, it is aggregated by one-minute granularity.
-If the time span is [12,48] hours, it is aggregated at a five-minute granularity.
-If the time span is (48, +inf) hours, it is aggregated at an hourly granularity.
OrderBy No OrderBy Sort query metrics.
Key: enter the tencentcloud api metric name. for details, see .
Value: specify the sorting method:.
-Asc: sorts query metrics in ascending order.
- desc: sort query metrics in descending order.
PageSize No Integer Maximum number of queried metrics. currently, up to 50 data entries can be displayed. the value range for pagesize is 1-50. submit pagesize to show the limited number based on the value of pagesize.

3. Output Parameters

Parameter Name Type Description
Records Array of Line Indicator result set.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Fetch Interface Analysis List Data

Scenario Description: View the total request volume of each interface over a specific period, or monitor metrics such as average response time, P99, maximum response time, and error rate. Key Configurations: * ViewName: Query the service_metric (basic performance metrics) view. * Metrics: Return request_count (request volume) data. * Filters: Specify span.kind (invocation role) and service.name (application name) as filter conditions. * GroupBy: Aggregate by operation (interface name). * Period: Set to 0, indicating no time-slicing; this calculates the total summary value for the entire time range. Request Parameter Example: Query the total number of requests for all interfaces under the service apm-test within a specified time range, grouped and displayed by interface name.

Input Example

{
  "InstanceId": "apm-instanceKey",
  "ViewName": "service_metric",
  "Metrics": [
    "request_count"
  ],
  "Filters": [
    {
      "Key": "span.kind",
      "Value": "server"
    },
    {
      "Key": "service.name",
      "Value": "apm-test"
    }
  ],
  "GroupBy": [
    "operation"
  ],
  "StartTime": 1768377000,
  "EndTime": 1768377900,
  "Period": 0
}

Output Example

{
    "Response": {
        "Records": [
            {
                "MetricName": "service_request_count_sum",
                "Tags": [
                    {
                        "Key": "operation",
                        "Value": "GET /mall/test"
                    }
                ],
                "TimeSerial": [],
                "DataSerial": [
                    18
                ]
            }
        ],
        "RequestId": "bfcc1a20-b6ff-455b-8fab-1d9883f4f629"
    }
}

Example2 Fetch API Analysis List Detail Data

Scenario Description:View the traffic trends and latency change trends of a specific service over a period of time. This is typically used for rendering line charts on the front end. Key Configurations: * ViewName: Query the service_metric (basic performance metrics) view. * Metrics: Return request_count (request volume) data. * Filters: Specify span.kind (invocation role), service.name (application name), and operation (interface/endpoint) as filter conditions. * GroupBy: Not specified, indicating that aggregation by specific dimensions is not required. * Period: Set to 1, representing aggregation by time slices. Request Parameter Example: Query the per-minute request count trend for the specific interface POST /mall/test under the application apm-test within a specified time range.

Input Example

{
  "InstanceId": "apm-instanceKey",
  "ViewName": "service_metric",
  "Metrics": [
    "request_count"
  ],
  "Filters": [
    {
      "Key": "span.kind",
      "Value": "server"
    },
    {
      "Key": "service.name",
      "Value": "apm-test"
    },
    {
      "Key": "operation",
      "Value": "POST /mall/test"
    }
  ],
  "StartTime": 1768377000,
  "EndTime": 1768377900,
  "Period": 1
}

Output Example

{
    "Response": {
        "Records": [
            {
                "MetricName": "service_request_count_sum",
                "Tags": [
                    {
                        "Key": "service.name",
                        "Value": "apm-test"
                    }
                ],
                "TimeSerial": [
                    1768377000,
                    1768377060,
                    1768377120
                ],
                "DataSerial": [
                    1,
                    null,
                    1
                ]
            }
        ],
        "RequestId": "4d62d7d5-e4b7-491b-874e-3563968f1626"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation Operation failed.
FailedOperation.AppIdNotMatchInstanceInfo The appid does not match the business system information.
FailedOperation.InstanceIdIsEmpty Business system id is empty.
FailedOperation.InstanceNotFound The apm business system does not exist.
FailedOperation.InvalidInstanceID Invalid business system id.
FailedOperation.MetricFiltersLackParams The metric data query lacks filter parameters in the query criteria.
FailedOperation.QueryTimeIntervalIsNotSupported Query time range not supported.
FailedOperation.ViewNameNotExistOrIllegal The view name does not exist or is invalid.
InvalidParameter.FiltersFieldsNotExistOrIllegal The field in filters does not exist or is invalid.
InvalidParameter.GroupByFieldsNotExistOrIllegal The field in groupby does not exist or is invalid.
InvalidParameter.MetricFiltersLackParams The service.name field must exist in filters, otherwise an error will occur.
InvalidParameter.MetricsFieldNotExistOrIllegal The field in metrics does not exist or is invalid.
InvalidParameter.MetricsFieldsNotAllowEmpty Metrics cannot be empty.
InvalidParameter.PeriodIsIllegal Period should not be empty, and can be 0 or 60.
InvalidParameter.QueryTimeIntervalIsNotSupported Query time not supported. up to 30 days of recent data can be queried.
InvalidParameter.ViewNameNotExistOrIllegal The view name does not exist or is invalid.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback