edit-icon download-icon

Collect statistics on message consumption by CID

Last Updated: Jan 30, 2018

OnsTrendGroupOutputTps interface queries statistical information of a consumed message obtained by the specified Consumer ID within a period of time.

Usage

When generating consumption data report for online environment, you can use this interface to query the amount or TPS statistics of the consumed messages.

Query scenario:

  • Query the curves of the total consumption
  • Query the curves of the consumption TPS

If the application party has a small number of messages which are not evenly distributed, then TPS query may lead to scarce result. Instead, Total query is recommended.

Request parameters

Name Type Required Description
OnsRegionId String Yes The region where the queried MQ is currently located. It can be obtained through the OnsRegionList method.
OnsPlatform String No The source of the request, which by default is POP platform.
PreventCache Long Yes It’s used for CSRF verification. Set it to the current system time.
Topic String Yes The name of the Topic to be queried
ConsumerId String Yes The name of CID to be queried
BeginTime Long Yes The start time stamp in milliseconds of the query range
EndTime Long Yes The end time stamp in milliseconds of the query range
Period Long Yes A sampling cycle in minutes, which can be 1, 5, or 10.
Type Integer Yes The query type (0 for total, and 1 for TPS)

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
data Data A data set

Data set definition

Name Type Description
Title String The table name
Records List(StatsDataDo) Information of a collection point

StatsDataDo data set definition

Name Type Description
X Long The horizontal axis with time stamps in milliseconds
Y Float The vertical axis for the data (TPS or total)
  • OnsTrendTopicInputTps: queries the statistics of message input

Example

  1. public static void main(String []args) {
  2. String regionId = "cn-hangzhou";
  3. String accessKey = "XXXXXXXXXXXXXXXXX";
  4. String secretKey = "XXXXXXXXXXXXXXXXX";
  5. String endPointName ="cn-hangzhou";
  6. String productName ="Ons";
  7. String domain ="ons.cn-hangzhou.aliyuncs.com";
  8. /**
  9. *Select Region based on the region you will access, and set the corresponding access point.
  10. */
  11. try {
  12. DefaultProfile.addEndpoint(endPointNameregionIdproductNamedomain);
  13. } catch (ClientException e) {
  14. e.printStackTrace();
  15. }
  16. IClientProfile profile= DefaultProfile.getProfile(regionIdaccessKeysecretKey);
  17. IAcsClient iAcsClient= new DefaultAcsClient(profile);
  18. OnsTrendGroupOutputTpsRequest request =new OnsTrendGroupOutputTpsRequest();
  19. request.setOnsRegionId("cn-qingdao-publictest");
  20. request.setPreventCache(System.currentTimeMillis());
  21. request.setAcceptFormat(FormatType.JSON);
  22. request.setTopic("MingduanTestAPI");
  23. request.setConsumerId("CID_Mingduan");
  24. request.setBeginTime(System.currentTimeMillis()-4*3600*1000);
  25. request.setEndTime(System.currentTimeMillis());
  26. request.setPeriod(1);
  27. request.setType(0);
  28. try {
  29. OnsTrendGroupOutputTpsResponse response =iAcsClient.getAcsResponse(request);
  30. OnsTrendGroupOutputTpsResponse.Data data =response.getData();
  31. System.out.println(data.getTitle()+"\n"+
  32. data.getRecords());
  33. } catch (ClientException e) {
  34. e.printStackTrace();
  35. }
Thank you! We've received your feedback.