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}.
A maximum of 20 requests can be initiated per second for this API.
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. |
| 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. |
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.
{
"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
}{
"Response": {
"Records": [
{
"MetricName": "service_request_count_sum",
"Tags": [
{
"Key": "operation",
"Value": "GET /mall/test"
}
],
"TimeSerial": [],
"DataSerial": [
18
]
}
],
"RequestId": "bfcc1a20-b6ff-455b-8fab-1d9883f4f629"
}
}
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.
{
"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
}{
"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"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
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. |
Feedback