Querying Metrics
Function
This API is used to query metrics. You can specify the namespace, metric name, dimension, sorting order, starting record, and the maximum number of records to filter the query results.
After a cloud service resource is deleted, its data remains cached for 3 hours. During this period, metrics of the resource can still be queried.
Calling Method
For details, see Calling APIs.
URI
GET /V1.0/{project_id}/metrics
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| project_id | String | Yes | Specifies a project ID. You can obtain the project ID by referring to Obtaining the Project ID. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| namespace | String | No |
|
| metric_name | String | No |
|
| dim | String | No |
|
| start | String | No |
|
| limit | Integer | No |
|
| order | String | No |
|
Request
- Request parameters
- Example request Example request 1: Query all metrics that can be monitored.
GET https://{Cloud Eye endpoint}/V1.0/{project_id}/metricsExample request 2: Query the connection count of the P2C VPN gateway whose ID is 4ae00000-0000-0000-0000-0000b1428ef7, and return 10 records sorted by timestamp in descending order.
GET https://{Cloud Eye endpoint}/V1.0/{project_id}/metrics?namespace=SYS.VPN&metric_name=gateway_connection_num&dim.0=p2c_vpn_gateway_id,4ae00000-0000-0000-0000-0000b1428ef7&limit=10&order=desc
Response
- Response parameters
Returned status code 200: successful query
Table 3 Parameters in the response body Parameter
Type
Description
metrics
Array of Metrics objects
Specifies metrics.
meta_data
MetaData object
Specifies the metadata of query results, including pagination information.
Table 4 Metrics Parameter
Type
Description
namespace
String
Specifies the namespace to which a metric belongs.
dimensions
Array of Dimensions objects
Specifies metric dimensions.
metric_name
String
Specifies a metric name, for example, gateway_connection_num.
unit
String
Specifies the unit of the metric.
Table 5 Dimensions Parameter
Type
Description
name
String
Specifies a dimension name.
- The dimension of a P2C VPN gateway is p2c_vpn_gateway_id.
- For details about the dimensions of S2C VPN, see the key field in Metrics (S2C Enterprise Edition VPN).
value
String
Specifies a dimension value, for example, the ID of a P2C VPN gateway.
Table 6 MetaData Parameter
Type
Description
count
Integer
Specifies the number of returned records.
marker
String
Specifies the start flag for querying the current page. If this parameter is left blank, the first page is queried. The marker for querying the next page is the marker in the meta_data object returned on the current page.
total
Integer
Specifies the total number of records in the metric query result.
- Example response
{ "metrics": [ { "namespace": "SYS.VPN", "dimensions": [ { "name": "p2c_vpn_gateway_id", "value": "72fe0000-0000-0000-0000-0000f0efd460" } ], "metric_name": "gateway_connection_num", "unit": "count" } ], "meta_data": { "count": 1, "marker": "SYS.VPN.gateway_connection_num.p2c_vpn_gateway_id:72fe0000-0000-0000-0000-0000f0efd460.index:756558082", "total": 16 } }
Status Codes
For details, see Status Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot