All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

GetMetricStatistics

Last updated:2026-03-18 14:12:49

GetMetricStatistics


Description

Field

Value

API Name

GetMetricStatistics

Request Method

GET

Endpoint

monitor.api.ksyun.com

VPC Internal Endpoint

monitor.internal.api.ksyun.com

Rate Limit Notice:

  • Per-user API call limit: up to 3,600 requests per minute (except for special data centers).

  • Maximum records returned per single request: 60,000.

  • If you need to query real-time data from within the last 15 minutes with high concurrency, please use the Batch Get Data API instead.


Debugging

It is recommended to use API Explorer.

Click to Debug

API Explorer provides online invocation, signature verification, SDK code generation, and quick API search. You can view the full request content and response for each call, and auto-generate SDK usage examples.


Request Parameters

The table below lists the API-specific request parameters and a subset of common parameters. For the full list of common parameters, see Common Request Parameters.

Parameter

Required

Type

Description

Action

Yes

String

Common parameter. Fixed value for this API: GetMetricStatistics.

Version

Yes

String

Common parameter. Fixed value for this API: 2010-05-25.

Namespace

Yes

String

Identifies a category of cloud product. Specifies the namespace.

InstanceID

Yes

String

The ID of the monitored instance. Special notes for certain product lines: KS3 — The instance ID is the BucketName, not the BucketID. MongoDB — Prefix the instance ID with user.

MetricName

Yes

String

The name of the monitoring metric.

StartTime

Yes

String

The start time of the query range. Format: 2023-07-19T16:00:50Z Example: 2023-07-19T16:00:50Z

EndTime

Yes

String

The end time of the query range. Format: 2023-07-19T16:09:50Z Important: Data collection may have a delay of approximately 2 minutes. The EndTime value should be at least 2 minutes behind the current time. For example, if the current time is 2023-07-19T16:11:50Z, then set EndTime=2023-07-19T16:09:50Z. Example: 2023-07-19T16:09:50Z

Aggregate

Yes

String

The aggregation method for the data. Supported values: Average, Max, Min. Note: If the returned data is inconsistent with what is shown in the console monitoring view, this parameter may be the cause. Example: Max

Period

No

String

The statistical granularity, in seconds. Note: This value must be an integer multiple of 60. An incorrect value may cause data to differ from the console display. When left empty (default), no downsampling is applied — data is returned at the product's native push frequency.


Response Parameters

Field

Type

Description

getMetricStatisticsResult

Object

Query result object.

datapoints

Object

Data points container.

member

Array of MetricDataPoint

The monitoring data points.

label

String

The monitoring metric name. Example: cpu.utilizition.total

responseMetadata

Object

Response metadata container.

requestId

String

Unique request ID.


Request Examples

Example 1: Query CPU Monitoring Data for a Cloud Instance (KEC)

Request

Replace ${region} with the appropriate region. See: Region Reference. Replace ${CommonParams} with the appropriate common parameters. See: Common Parameters.

bash

curl -X GET 'https://monitor.${region}.api.ksyun.com/?Action=GetMetricStatistics&Version=2010-05-25&Namespace=KEC&StartTime=2021-12-13T17:52:00Z&EndTime=2021-12-13T17:56:00Z&InstanceID=6e98888-4bbe-4da5-baef-91306bce03e9&MetricName=cpu.utilizition.total&Period=60&Aggregate=average,max,min,sum,count' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'host: monitor.api.ksyun.com' \
-H 'cache-control: no-cache' \
-H ${CommonParams}
Successful Response

Both XML and JSON formats are supported.

JSON Format

json

{
    "getMetricStatisticsResult": {
        "datapoints": {
            "member": [
                {
                    "timestamp": "2021-12-13T17:52:00Z",
                    "unixTimestamp": 1639389120000,
                    "average": "0.136",
                    "max": "0.136",
                    "min": "0.136",
                    "sampleCount": "1",
                    "sum": "0"
                },
                {
                    "timestamp": "2021-12-13T17:53:00Z",
                    "unixTimestamp": 1639389180000,
                    "average": "0.136",
                    "max": "0.136",
                    "min": "0.136",
                    "sampleCount": "1",
                    "sum": "0"
                },
                {
                    "timestamp": "2021-12-13T17:54:00Z",
                    "unixTimestamp": 1639389240000,
                    "average": "0.136",
                    "max": "0.136",
                    "min": "0.136",
                    "sampleCount": "1",
                    "sum": "0"
                },
                {
                    "timestamp": "2021-12-13T17:55:00Z",
                    "unixTimestamp": 1639389300000,
                    "average": "0.136",
                    "max": "0.136",
                    "min": "0.136",
                    "sampleCount": "1",
                    "sum": "0"
                },
                {
                    "timestamp": "2021-12-13T17:56:00Z",
                    "unixTimestamp": 1639389360000,
                    "average": "0.136",
                    "max": "0.136",
                    "min": "0.136",
                    "sampleCount": "1",
                    "sum": "0"
                }
            ]
        },
        "label": "cpu.utilizition.total"
    },
    "responseMetadata": {
        "requestId": "3a037487-33c6-4c01-b68a-1545f7312fed"
    }
}

XML Format

xml

<GetMetricStatisticsResponse xmlns="https://ksyun.kingeyes.com/">
    <GetMetricStatisticsResult>
        <Datapoints>
            <member>
                <Average>0.136</Average>
                <Max>0.136</Max>
                <Min>0.136</Min>
                <SampleCount>1</SampleCount>
                <Sum>0</Sum>
                <Timestamp>2021-12-13T17:52:00Z</Timestamp>
                <UnixTimestamp>1639389120000</UnixTimestamp>
            </member>
            <member>
                <Average>0.136</Average>
                <Max>0.136</Max>
                <Min>0.136</Min>
                <SampleCount>1</SampleCount>
                <Sum>0</Sum>
                <Timestamp>2021-12-13T17:53:00Z</Timestamp>
                <UnixTimestamp>1639389180000</UnixTimestamp>
            </member>
            <member>
                <Average>0.136</Average>
                <Max>0.136</Max>
                <Min>0.136</Min>
                <SampleCount>1</SampleCount>
                <Sum>0</Sum>
                <Timestamp>2021-12-13T17:54:00Z</Timestamp>
                <UnixTimestamp>1639389240000</UnixTimestamp>
            </member>
            <member>
                <Average>0.136</Average>
                <Max>0.136</Max>
                <Min>0.136</Min>
                <SampleCount>1</SampleCount>
                <Sum>0</Sum>
                <Timestamp>2021-12-13T17:55:00Z</Timestamp>
                <UnixTimestamp>1639389300000</UnixTimestamp>
            </member>
            <member>
                <Average>0.136</Average>
                <Max>0.136</Max>
                <Min>0.136</Min>
                <SampleCount>1</SampleCount>
                <Sum>0</Sum>
                <Timestamp>2021-12-13T17:56:00Z</Timestamp>
                <UnixTimestamp>1639389360000</UnixTimestamp>
            </member>
        </Datapoints>
        <Label>cpu.utilizition.total</Label>
    </GetMetricStatisticsResult>
    <ResponseMetadata>
        <RequestId>3a037487-33c6-4c01-b68a-1545f7312fed</RequestId>
    </ResponseMetadata>
</GetMetricStatisticsResponse>
Error Response

Both XML and JSON formats are supported.

JSON Format

json

{
    "requestid": "7106664e-bce9-4871-b5df-9cf6e25ce142",
    "error": {
        "type": "sender",
        "code": "InvalidParameterValue",
        "message": "Invalid `StartTime` parameter value, time type should be 'yyyy-MM-ddTHH:mm:ssZ', like '2016-05-11T15:00:00Z'."
    }
}

Error Codes

The table below lists only the error codes specific to this API's business logic. For all other error codes, refer to Common Error Codes.

On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback