You can call the DescribeDBInstanceMetrics operation to query the Enhanced Monitoring metrics that are enabled for an ApsaraDB RDS for PostgreSQL instance.

Prerequisite

The instance runs PostgreSQL.

For more information, see View the Enhanced Monitoring metrics of an ApsaraDB RDS for PostgreSQL instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeDBInstanceMetrics

The operation that you want to perform. Set the value to DescribeDBInstanceMetrics.

DBInstanceName String Yes pgm-bp1s1j103lo6****

The ID of the instance. You can call the DescribeDBInstances operation to query the ID of the instance.

ResourceGroupId String No rg-acfmy*****

The ID of the resource group.

Response parameters

Parameter Type Example Description
TotalRecordCount Integer 1

The total number of Enhanced Monitoring metrics that are enabled for the instance.

RequestId String 318C3754-F6D0-54BB-A55C-23EAA04708B7

The ID of the request.

Items Array of Metrics

An array consisting of the Enhanced Monitoring metrics that are enabled for the instance.

GroupKey String os.cpu_usage

The key of the group to which the Enhanced Monitoring metric belongs.

SortRule Integer 1

The serial number of the Enhanced Monitoring metric.

Description String The system CPU utilization. The value of this metric is calculated based on the following formula: System CPU utilization = CPU resources consumed to run kernel code/Total CPU resources.

The description of the Enhanced Monitoring metric.

Unit String %

The unit of the Enhanced Monitoring metric.

MetricsKey String os.cpu_usage.sys.avg

The key of the Enhanced Monitoring metric.

GroupKeyType String CPU utilization

The name of the group to which the Enhanced Monitoring metric belongs.

Method String avg

The method that is used to aggregate the monitoring data of the Enhanced Monitoring metric. Valid values:

  • avg: The system calculates the average value of the Enhanced Monitoring metric.
  • min: The system calculates the minimum value of the Enhanced Monitoring metric.
  • max: The system calculates the maximum value of the Enhanced Monitoring metric.
Dimension String os

The category of the Enhanced Monitoring metric. Valid values:

  • os: OS metric
  • db: database metric
MetricsKeyAlias String os.cpu_usage.sys

The alias of the Enhanced Monitoring metric.

DBInstanceName String rm-bp1*****

The ID of the instance.

Examples

Sample requests

http(s)://rds.aliyuncs.com/?Action=DescribeDBInstanceMetrics
&DBInstanceName=pgm-bp1s1j103lo6****
&<Common request parameters>

Sample success response

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeDBInstanceMetrics>
<TotalRecordCount>1</TotalRecordCount>
<RequestId>318C3754-F6D0-54BB-A55C-23EAA04708B7</RequestId>
  <Items>
     <Description>The system CPU utilization. The value of this metric is calculated based on the following formula: System CPU utilization = CPU resources consumed to run kernel code/Total CPU resources.</Description>
     <GroupKeyType>CPU utilization</GroupKeyType>
     <MetricsKey>os.cpu_usage.sys.avg</MetricsKey>
     <GroupKey>os.cpu_usage</GroupKey>
     <Dimension>os</Dimension>
     <Method>avg</Method>
     <Unit>%</Unit>
     <SortRule>1</SortRule>
     <MetricsKeyAlias>os.cpu_usage.sys</MetricsKeyAlias>
  </Items>
</DescribeDBInstanceMetrics>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "TotalRecordCount" : 1,
  "RequestId" : "318C3754-F6D0-54BB-A55C-23EAA04708B7",
  "Items" : {
    "Description": "The system CPU utilization. The value of this metric is calculated based on the following formula: System CPU utilization = CPU resources consumed to run kernel code/Total CPU resources.",
    "GroupKeyType": "CPU utilization",
    "MetricsKey" : "os.cpu_usage.sys.avg",
    "GroupKey" : "os.cpu_usage",
    "Dimension" : "os",
    "Method" : "avg",
    "Unit" : "%",
    "SortRule" : 1,
    "MetricsKeyAlias" : "os.cpu_usage.sys"
  }
}

Error codes

HTTP status code Error code Error message Description
400 InvalidInstanceMetricsConfigs.NotFound The specified instance has no metrics configs The error message returned because no Enhanced Monitoring metrics are configured for the instance.
400 InvalidDBInstanceEngineType.Format the DB instance engine type does not support this operation. The error message returned because the operation is not supported by the database engine of the instance.
404 InvalidDBInstanceName.NotFound The database instance does not exist. The error message returned because the name of the instance cannot be found. Verify the instance name and try again.

For a list of error codes, visit the API Error Center.