edit-icon download-icon

QueryMetricList

Last Updated: Apr 11, 2018

Query the metric data of a specific product instance during a specified time period.

Request type

GET

Request parameters

Name Type Required Description
Action String Yes Operation interface name, required parameter. Value: QueryMetricList.
Project String Yes Name space. It indicates the product to which the metric data belongs, for example, “acs_ecs_dashboard” or “acs_rds_dashboard”.
Metric String Yes Metric name.
Period String No Time interval, calculated in seconds, for example, 60, 300, or 900. If this field is not specified, raw data is queried based on the report period stated during metric registration. If this field is specified, corresponding statistics are queried based on the specified period.
StartTime String No Start time, which can be a millisecond value counted from 00:00:00, January 1, 1970, or formatted data, for example, 2015-10-20 00:00:00.
EndTime String No End time, which can be a millisecond value counted from 00:00:00, January 1, 1970, or formatted data, for example, 2015-10-20 00:00:00.
Dimensions String No Key-value set used to filter metric data. The key can use one or more dimensionKeys stated during metric registration and the value relates to this key. instanceId is required. The Map object must be a JSON string. Dimensions must be input in order.
Express String No The express parameter is used to calculate metric data and includes the extend keyword. This parameter is typically used to convert the unit of metric data through the four arithmetic operations. For example, in {“sum”:”sum 1000”}, “sum” is the name of the extend field and “sum 1000” is an arithmetic operation for the extended field. Multiple extend fields are supported, for example, {“sumExtend”:”sum * 1000”,”avgExtend”:”avg / 1000”}.
Length String No Size of each query, used in paging query. Default value: 1000.
Cursor String No Cursor.

Parameter description

  • For more information about how to assign values to Project, Metric, Period and Dimensions, see Preset metric reference.

  • startTime and endTime are in left-open and right-closed mode, and startTime cannot be the same as or later than endTime.

  • Cursor is a parameter in paging mode. As long as it exists, it means there is a next page. If it is null, it means there is no next page.

  • Generally, the Period value can be 60 seconds (1 minute), 300 seconds (5 minutes), or 900 seconds (15 minutes). You can set the Period parameter based on the document requirements and query scenario. For example, to query data for a specified day, if you set Period to 60, then 1,000 data items are returned. (Actually, 1,440 items are available but only 1,000 items are returned since the maximum return value cannot be greater than 1,000.) If you set Period to 300, then 288 data items are returned.

  • The interface supports RAM subaccount calls. The operation descriptor during authorization is “cms:QueryMetricList” and the resource descriptor is “*”.

Return parameters

Name Type Description
Period String Time interval, always calculated in seconds, for example, 60, 300, or 900.
Cursor String Cursor.
Datapoints String Metric data list, in the following format: { “timestamp”: 1490164200000, “Maximum”: 100, “userId”: “1234567898765432”, “Minimum”: 4.55, “instanceId”: “i-bp18abl200xk9599ck7c”, “Average”: 93.84 }.
Code String Status code. Code 200 is returned if no exception occurs.
Success Boolean Whether the current query is successful. If there is an exception on the server side, the returned value is “false” (and “true” otherwise).
Message String Status description. The message is null when Code is 200.
RequestId String If any issue occurs with querying, you can provide this field to a technical engineer to troubleshoot.

Error code

Error code Description Meaning
400 Bad Request Syntactic error of the client request
403 Forbidden Not authorized
404 Not Found Client error, not found
500 Internal Server Error Server error
200 OK Normal

Examples

  • Request example
  1. http://metrics.cn-hangzhou.aliyuncs.com/?Action=QueryMetricList
  2. &EndTime=2017-05-17+11%3A30%3A27
  3. &StartTime=2017-05-17+11%3A20%3A27
  4. &Period=60
  5. &Dimensions=%7B%22instanceId%22%3A%22i-abcdefgh123456%22%7D
  6. &Timestamp=2017-03-22T09%3A30%3A57Z
  7. &Project=acs_ecs_dashboard
  8. &Metric=cpu_idle
  9. &express={"extend":{"avgExtend":"Average*10"}}
  • Return example

XML format

  1. <QueryMetricListResponse>
  2. <Period>60</Period>
  3. <Datapoints>
  4. <Datapoints>
  5. <timestamp>1490152860000</timestamp>
  6. <Maximum>100</Maximum>
  7. <userId> 1234567898765432</userId>
  8. <Minimum>93.1</Minimum>
  9. <instanceId>i-abcdefgh123456</instanceId>
  10. <Average>99.52</Average>
  11. <avgExtend>995.2</avgExtend>
  12. </Datapoints>
  13. <Datapoints>
  14. <timestamp>1490152920000</timestamp>
  15. <Maximum>100</Maximum>
  16. <userId> 1234567898765432 </userId>
  17. <Minimum>92.59</Minimum>
  18. <instanceId>i-abcdefgh123456</instanceId>
  19. <Average>99.49</Average>
  20. <avgExtend>994.9</avgExtend>
  21. </Datapoints>
  22. <Datapoints>
  23. <timestamp>1490152980000</timestamp>
  24. <Maximum>100</Maximum>
  25. <userId>1234567898765432</userId>
  26. <Minimum>92.86</Minimum>
  27. <instanceId>i-abcdefgh123456</instanceId>
  28. <Average>99.44</Average>
  29. <avgExtend>994.4</avgExtend>
  30. </Datapoints>
  31. <Datapoints>
  32. <timestamp>1490153040000</timestamp>
  33. <Maximum>100</Maximum>
  34. <userId>1234567898765432</userId>
  35. <Minimum>91.43</Minimum>
  36. <instanceId>i-abcdefgh123456</instanceId>
  37. <Average>99.36</Average>
  38. <avgExtend>993.6</avgExtend>
  39. </Datapoints>
  40. <Datapoints>
  41. <timestamp>1490153100000</timestamp>
  42. <Maximum>100</Maximum>
  43. <userId>1234567898765432</userId>
  44. <Minimum>93.55</Minimum>
  45. <instanceId>i-abcdefgh123456</instanceId>
  46. <Average>99.51</Average>
  47. <avgExtend>995.1</avgExtend>
  48. </Datapoints>
  49. <Datapoints>
  50. <timestamp>1490153160000</timestamp>
  51. <Maximum>100</Maximum>
  52. <userId>1234567898765432</userId>
  53. <Minimum>93.1</Minimum>
  54. <instanceId>i-abcdefgh123456</instanceId>
  55. <Average>99.52</Average>
  56. <avgExtend>995.2</avgExtend>
  57. </Datapoints>
  58. <Datapoints>
  59. <timestamp>1490153220000</timestamp>
  60. <Maximum>100</Maximum>
  61. <userId>1234567898765432</userId>
  62. <Minimum>92.59</Minimum>
  63. <instanceId>i-abcdefgh123456</instanceId>
  64. <Average>99.42</Average>
  65. <avgExtend>994.2</avgExtend>
  66. </Datapoints>
  67. <Datapoints>
  68. <timestamp>1490153280000</timestamp>
  69. <Maximum>100</Maximum>
  70. <userId>1234567898765432</userId>
  71. <Minimum>91.18</Minimum>
  72. <instanceId>i-abcdefgh123456</instanceId>
  73. <Average>99.34</Average>
  74. <avgExtend>993.4</avgExtend>
  75. </Datapoints>
  76. <Datapoints>
  77. <timestamp>1490153340000</timestamp>
  78. <Maximum>100</Maximum>
  79. <userId>1234567898765432</userId>
  80. <Minimum>92.86</Minimum>
  81. <instanceId>i-abcdefgh123456</instanceId>
  82. <Average>99.46</Average>
  83. <avgExtend>994.6</avgExtend>
  84. </Datapoints>
  85. <Datapoints>
  86. <timestamp>1490153400000</timestamp>
  87. <Maximum>100</Maximum>
  88. <userId>1234567898765432</userId>
  89. <Minimum>91.18</Minimum>
  90. <instanceId>i-abcdefgh123456</instanceId>
  91. <Average>99.35</Average>
  92. <avgExtend>993.5</avgExtend>
  93. </Datapoints>
  94. </Datapoints>
  95. <RequestId>6661EC50-8625-4161-B349-E0DD59002AB7</RequestId>
  96. <Success>true</Success>
  97. <Code>200</Code>
  98. </QueryMetricListResponse>

JSON format

  1. {
  2. "Period": "60",
  3. "Datapoints": [
  4. {
  5. "timestamp": 1490152860000,
  6. "Maximum": 100,
  7. "userId": "1234567898765432",
  8. "Minimum": 93.1,
  9. "instanceId": "i-abcdefgh123456",
  10. "Average": 99.52
  11. "avgExtend": 995.2
  12. },
  13. {
  14. "timestamp": 1490152920000,
  15. "Maximum": 100,
  16. "userId": "1234567898765432",
  17. "Minimum": 92.59,
  18. "instanceId": "i-abcdefgh123456",
  19. "Average": 99.49
  20. "avgExtend": 994.9
  21. },
  22. {
  23. "timestamp": 1490152980000,
  24. "Maximum": 100,
  25. "userId": "1234567898765432",
  26. "Minimum": 92.86,
  27. "instanceId": "i-abcdefgh123456",
  28. "Average": 99.44
  29. "avgExtend": 994.4
  30. },
  31. {
  32. "timestamp": 1490153040000,
  33. "Maximum": 100,
  34. "userId": "1234567898765432",
  35. "Minimum": 91.43,
  36. "instanceId": "i-abcdefgh123456",
  37. "Average": 99.36
  38. "avgExtend": 993.6
  39. },
  40. {
  41. "timestamp": 1490153100000,
  42. "Maximum": 100,
  43. "userId": "1234567898765432",
  44. "Minimum": 93.55,
  45. "instanceId": "i-abcdefgh123456",
  46. "Average": 99.51
  47. "avgExtend": 995.1
  48. },
  49. {
  50. "timestamp": 1490153160000,
  51. "Maximum": 100,
  52. "userId": "1234567898765432",
  53. "Minimum": 93.1,
  54. "instanceId": "i-abcdefgh123456",
  55. "Average": 99.52
  56. "avgExtend": 995.2
  57. },
  58. {
  59. "timestamp": 1490153220000,
  60. "Maximum": 100,
  61. "userId": "1234567898765432",
  62. "Minimum": 92.59,
  63. "instanceId": "i-abcdefgh123456",
  64. "Average": 99.42
  65. "avgExtend": 994.2
  66. },
  67. {
  68. "timestamp": 1490153280000,
  69. "Maximum": 100,
  70. "userId": "1234567898765432",
  71. "Minimum": 91.18,
  72. "instanceId": "i-abcdefgh123456",
  73. "Average": 99.34
  74. "avgExtend": 993.4
  75. },
  76. {
  77. "timestamp": 1490153340000,
  78. "Maximum": 100,
  79. "userId": "1234567898765432",
  80. "Minimum": 92.86,
  81. "instanceId": "i-abcdefgh123456",
  82. "Average": 99.46
  83. "avgExtend": 994.6
  84. },
  85. {
  86. "timestamp": 1490153400000,
  87. "Maximum": 100,
  88. "userId": "1234567898765432",
  89. "Minimum": 91.18,
  90. "instanceId": "i-abcdefgh123456",
  91. "Average": 99.35
  92. "avgExtend": 993.5
  93. }
  94. ],
  95. "RequestId": "6A5F022D-AC7C-460E-94AE-B9E75083D027",
  96. "Success": true,
  97. "Code": "200"
  98. }
Thank you! We've received your feedback.