• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. Metrics and Logs (Proprietary APIs)
  5. Obtaining Monitoring Metrics of All Application Instances in a Specified Namespace in a Cluster

Obtaining Monitoring Metrics of All Application Instances in a Specified Namespace in a Cluster

Function

This API is used to obtain monitoring metrics of all application instances in a specified namespace in a cluster.

URI

GET /api/v1/ops/clusters/{clusteruuid}/namespaces/{namespaces_name}/pods/metrics

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

clusteruuid

Yes

uuid of the cluster on which the application runs.

The cluster uuid is obtained using the API described in Obtaining Information About All Clusters.

namespace_name

Yes

Application namespace obtained using the API described in Listing or Watching Objects of Kind Namespace.

NOTICE:

For applications created by using the CCE console, their namespace is default.

startTime

Yes

NOTICE:

The timeFrame and startTime/endTime are mutually exclusive.

Unix time stamp of the metric query start time.

The startTime is accurate to the second and must be used together with the endTime.

endTime

Yes

NOTICE:

The timeFrame and startTime/endTime are mutually exclusive.

Unix time stamp of the metric query end time.

The endTime is accurate to the second and must be used together with the startTime.

timeFrame

Yes

NOTICE:

The timeFrame and startTime/endTime are mutually exclusive.

Time range (in seconds) of metric query.

The maxQueryTime is 7*24*60*60 seconds.

For example, timeFrame=120 means monitoring metrics over the last 120 seconds will be returned.

period

No

Sampling period (in seconds).

Historical monitoring metrics are sampled by means of interpolation.

If this parameter is left unspecified or set to 1, raw monitoring metrics are returned.

Value:

  • 1
  • 30
  • 60
  • 300
  • 600
  • 1200
  • 3600

fillPolicy

No

Policy for inserting a blank filler field in the event that no monitoring metrics are available for sampling.

If this parameter is left unspecified, no sample is produced for the time when no monitoring metrics are generated. This parameter must be used with the period parameter.

Value:

  • nan: The blank filler field NaN is inserted in the event that no monitoring metrics are available for sampling.
  • zero: The blank filler field 0 is inserted in the event that no monitoring metrics are available for sampling.

Request

Request parameters:

N/A

Example response:

curl "http://{cce-domain-name}/api/v1/ops/clusters/{clusteruuid}/namespaces/{namespaces_name}/pods/metrics?startTime=1469759447&endTime=1469759760&period=60&fillPolicy=nan"
curl "http://{cce-domain-name}/api/v1/ops/clusters/{clusteruuid}/namespaces/{namespaces_name}/pods/metrics?timeFrame=120"

Response

Response parameters:

For the description about response parameters, see Table 2.

Example response:

[
  {
    "kind": "pod",
    "apiVersion": "v1.0",
    "metadata": {
      "name": "test1701-ro9au",
      "uuid": "0ffab973-5bfa-11e6-b454-fa163e83313b"
    },
    "spec": {
      "metricsList": [
        {
          "metric_name": "cpu_util",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 0,
              "unit": "millicores"
            }
          ]
        },
        {
          "metric_name": "mem_util",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 8.49609375,
              "unit": "MB"
            }
          ]
        },
        {
          "metric_name": "network_rx_rate",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 0,
              "unit": "bps"
            }
          ]
        },
        {
          "metric_name": "network_tx_rate",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 0,
              "unit": "bps"
            }
          ]
        }
      ]
    }
  },
  {
    "kind": "pod",
    "apiVersion": "v1.0",
    "metadata": {
      "name": "test1701-6ivm0",
      "uuid": "e5b0b98e-5c01-11e6-b454-fa163e83313b"
    },
    "spec": {
      "metricsList": [
        {
          "metric_name": "cpu_util",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 0,
              "unit": "millicores"
            }
          ]
        },
        {
          "metric_name": "mem_util",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 8.49609375,
              "unit": "MB"
            }
          ]
        },
        {
          "metric_name": "network_rx_rate",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 0,
              "unit": "bps"
            }
          ]
        },
        {
          "metric_name": "network_tx_rate",
          "datapoints": [
            {
              "timestamp": 1470721320,
              "metricvalue": 0,
              "unit": "bps"
            }
          ]
        }
      ]
    }
  }
]

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

Monitoring information about all application instances in a specified namespace in a cluster is returned.

For the description about status codes, see Status Codes.