Querying Monitoring Data in Batches
Function
You can query the monitoring data of specified metrics within a specified time range and specified granularities in batches. At present, you can query the monitoring data of a maximum of 10 metrics in batches.
URI
POST /V1.0/{project_id}/batch-query-metric-data
- Parameter description
Table 1 Parameter description Parameter
Mandatory
Description
project_id
Yes
Specifies the project ID.
For details about how to obtain the project ID, see Obtaining a Project ID.
Request
- The size of a POST request cannot exceed 512 KB. Otherwise, the request will be denied.
- The default maximum query intervals of different periods are different.
If period is 1, the maximum interval between from and to is 4 hours. If the interval between from and to is longer than 4 hours, adjust the value of from to to - 4*3600*1000.
If period is 300, the maximum interval between from and to is 1 day. If the interval between from and to is longer than 1 day, adjust the value of from to to - 24*3600*1000.
If period is 1200, the maximum interval between from and to is 3 days. If the interval between from and to is longer than three days, adjust the value of from to to - 3*24*3600*1000.
If period is 3600, the maximum interval between from and to is 10 days. If the interval between from and to is longer than 10 days, adjust the value of from to to - 10*24*3600*1000.
If period is 14400, the maximum interval between from and to is 30 days. If the interval between from and to is longer than 30 days, adjust the value of from to to - 30*24*3600*1000.
If period is 86400, the maximum interval between from and to is 180 days. If the interval between from and to is longer than 180 days, adjust the value of from to to - 180*24*3600*1000.
- Request parameters
Table 2 Request parameters Parameter
Mandatory
Type
Description
metrics
Yes
Arrays of objects
Specifies the metric data. The maximum length of the array is 10.
For details, see Table 3.
from
Yes
long
Specifies the start time of the query. The value is a UNIX timestamp and the unit is ms. Set the value of from to at least one period earlier than the current time. Rollup aggregates the raw data generated within a period to the start time of the period. Therefore, if values of from and to are within a period, the query result will be empty due to the rollup failure. You are advised to set from to be at least one period earlier than the current time. Take the 5-minute period as an example. If it is 10:35 now, the raw data generated between 10:30 and 10:35 will be aggregated to 10:30. Therefore, in this example, if the value of period is 5 minutes, the value of from should be 10:30 or earlier.
NOTE:Cloud Eye rounds up the value of from based on the level of granularity required to perform the rollup.
to
Yes
long
Specifies the end time of the query. The value is a UNIX timestamp and the unit is ms. The value of parameter from must be earlier than that of parameter to.
period
Yes
String
Specifies how often Cloud Eye aggregates data.
Possible values are:
- 1: Cloud Eye performs no aggregation and displays raw data.
- 300: Cloud Eye aggregates data every 5 minutes.
- 1200: Cloud Eye aggregates data every 20 minutes.
- 3600: Cloud Eye aggregates data every 1 hour.
- 14400: Cloud Eye aggregates data every 4 hours.
- 86400: Cloud Eye aggregates data every 24 hours.
filter
Yes
String
Specifies the data rollup method. The following methods are supported:
- average: Cloud Eye calculates the average value of metric data within a rollup period.
- max: Cloud Eye calculates the maximum value of metric data within a rollup period.
- min: Cloud Eye calculates the minimum value of metric data within a rollup period.
- sum: Cloud Eye calculates the sum of metric data within a rollup period.
- variance: Cloud Eye calculates the variance value of metric data within a rollup period.
The value of filter does not affect the query result of raw data. (The period is 1.)
Table 3 metrics field data structure description Parameter
Mandatory
Type
Description
namespace
Yes
String
Specifies the metric namespace. Its value must be in the service.item format and can contain 3 to 32 characters.
service and item each must be a string that starts with a letter and contains only uppercase letters, lowercase letters, digits, and underscores (_).
dimensions
Yes
Arrays of objects
Specifies the list of the metric dimensions.
Each dimension is a JSON object, and its structure is as follows:
{
"name": "instance_id",
"value": "33328f02-3814-422e-b688-bfdba93d4050"
}
For details, see Table 4.
metric_name
Yes
String
The value can be a string of 1 to 64 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, and underscores (_).
Table 4 dimensions field data structure description Parameter
Mandatory
Type
Description
name
Yes
String
Specifies the dimension. For example, the ECS dimension is instance_id. For details about the dimension of each service, see the key column in Services Interconnected with Cloud Eye.
The value can be a string of 1 to 32 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).
value
Yes
String
Specifies the dimension value, for example, an ECS ID.
The value can be a string of 1 to 256 characters and must start with a letter or a digit and contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).
- Example request
{ "metrics" : [ { "namespace": "SYS.ECS", "dimensions": [ { "name": "instance_id", "value": "faea5b75-e390-4e2b-8733-9226a9026070" } ], "metric_name": "disk_write_bytes_rate" }, { "namespace": "SYS.ECS", "dimensions": [ { "name": "instance_id", "value": "06b4020f-461a-4a52-84da-53fa71c2f42b" } ], "metric_name": "disk_write_requests_rate" } ], "from": 1484153313000, "to": 1484653313000, "period": "1", "filter": "average" }
Response
- Response parameters
Table 5 Response parameters Parameter
Type
Description
metrics
Arrays of objects
Specifies the metric data.
For details, see Table 6.
Table 6 metrics field data structure description Parameter
Type
Description
unit
String
Specifies the metric unit.
datapoints
Arrays of objects
Specifies the metric data list. Since Cloud Eye rounds up the value of from based on the level of granularity for data query, datapoints may contain more data points than expected.
For details, see Table 8.
namespace
String
Specifies the metric namespace. The value must be in the service.item format and can contain 3 to 32 characters. service and item each must be a string that starts with a letter and contains only uppercase letters, lowercase letters, digits, and underscores (_).
dimensions
Arrays of objects
Specifies the list of metric dimensions.
Each dimension is a JSON object, and its structure is as follows:
{
"name": "instance_id",
"value": "33328f02-3814-422e-b688-bfdba93d4050"
}
For details, see Table 7.
metric_name
String
The value can be a string of 1 to 64 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, and underscores (_).
Table 7 dimensions field data structure description Parameter
Type
Description
name
String
Specifies the dimension. For example, the ECS dimension is instance_id. For details about the dimension of each service, see the key column in Services Interconnected with Cloud Eye.
The value can be a string of 1 to 32 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).
value
String
Specifies the dimension value, for example, an ECS ID.
The value can be a string of 1 to 256 characters and must start with a letter or a digit and contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).
Table 8 datapoints field data structure description Parameter
Type
Description
average
double
Specifies the metric value. The value of this parameter is the same as that of parameter filter. The value can be max/min/average/sum/variance.
max
double
Specifies the metric value. The value of this parameter is the same as that of parameter filter. The value can be max/min/average/sum/variance.
min
double
Specifies the metric value. The value of this parameter is the same as that of parameter filter. The value can be max/min/average/sum/variance.
sum
double
Specifies the metric value. The value of this parameter is the same as that of parameter filter. The value can be max/min/average/sum/variance.
variance
double
Specifies the metric value. The value of this parameter is the same as that of parameter filter. The value can be max/min/average/sum/variance.
timestamp
long
Specifies the time when the metric is collected. It is a UNIX timestamp and the unit is ms.
- Example response
{ "metrics": [ { "unit": "request/s", "datapoints": [ { "average": 0, "timestamp": 1484401920000 }, { "average": 1, "timestamp": 1484407920000 } ], "namespace": "MINE.APP", "dimensions": [ { "name": "instance_id", "value": "33328f02-3814-422e-b688-bfdba93d4050" } ], "metric_name": "cpu_util" }, { "unit": "request/s", "datapoints": [ { "average": 2.3, "timestamp": 1484401920000 }, { "average": 1.2, "timestamp": 1484407920000 } ], "namespace": "MINE.APP", "dimensions": [ { "name": "instance_id", "value": "33328f02-3814-422e-b688-bfdba93d4051" } ], "metric_name": "cpu_util" } ] }
Returned Values
- Normal
- Abnormal
Returned Values
Description
400 Bad Request
Request error.
401 Unauthorized
The authentication information is not provided or is incorrect.
403 Forbidden
You are forbidden to access the page requested.
408 Request Timeout
The request timed out.
429 Too Many Requests
Concurrent requests are excessive.
500 Internal Server Error
Failed to complete the request because of an internal service error.
503 Service Unavailable
The service is currently unavailable.
Error Code
For details, see Error Codes.
Last Article: Adding Monitoring Data
Next Article: Querying the Host Configuration
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.