edit-icon download-icon

Collect statistics on message production by Topic

Last Updated: Jan 30, 2018

OnsTrendTopicInputTps interface queries report data of message input for the specified Topic within a period of time.

Usage

This interface can be used for retrieving Topic message data in online environment. Depending on the type, you can query the Topic input amount in a specified time range, or you can query the TPS data in that time range.

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
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)
  • OnsTrendGroupOutputTps: queries the statistics of the message consumption of a CID

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. OnsTrendTopicInputTpsRequest request =new OnsTrendTopicInputTpsRequest();
  19. request.setOnsRegionId("cn-qingdao-publictest");
  20. request.setPreventCache(System.currentTimeMillis());
  21. request.setAcceptFormat(FormatType.JSON);
  22. request.setTopic("MingduanTestAPI");
  23. request.setBeginTime(System.currentTimeMillis()-4*3600*1000);
  24. request.setEndTime(System.currentTimeMillis());
  25. request.setPeriod(1);
  26. request.setType(0);
  27. try {
  28. OnsTrendTopicInputTpsResponse response =iAcsClient.getAcsResponse(request);
  29. OnsTrendTopicInputTpsResponse.Data data =response.getData();
  30. System.out.println(data.getTitle()+"\n"+
  31. data.getRecords());
  32. } catch (ClientException e) {
  33. e.printStackTrace();
  34. }
  35. }
Thank you! We've received your feedback.