Queries the statistics on produced messages in a specified topic within a specified period of time.

Usage notes

You can call this operation to query online message statistics on a specified topic. You can also call this operation to query the number of messages written into the topic or the transactions per second (TPS) curve within a specified period of time as needed.

Note If the message volume is small and messages are unevenly distributed for your application, the TPS curve may be flat. We recommend that you query the total number of messages written into the topic.

QPS limit

The queries-per-minute (QPM) limit on this operation is 15 per user. Throttling is triggered when the number of calls to this operation per minute exceeds the QPM limit. Throttling may affect your business. Therefore, call this operation based on your needs. For more information, see QPS limits.

Authorization information

By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after they are authorized to use it. The following table lists the authorization information of this operation. For more information, see Policies and examples.

API

Action

Resource with a namespace

Resource without a namespace

OnsTrendTopicInputTps

mq:QueryTrendTopicInputTps

acs:mq:*:*:{instanceId}%{topic}

acs:mq:*:*:{topic}

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes OnsTrendTopicInputTps

The operation that you want to perform. Set the value to OnsTrendTopicInputTps.

BeginTime Long Yes 1570852800000

The timestamp that indicates the beginning of the time range to query. Unit: milliseconds.

EndTime Long Yes 1570868400000

The timestamp that indicates the end of the time range to query. Unit: milliseconds.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance where the topic is located.

Topic String Yes test

The name of the topic that you want to query.

Type Integer Yes 0

The type of statistics that you want to query. Valid values:

  • 0: queries the number of messages written into the topic within a specified period of time.
  • 1: queries the TPS curve of the topic within a specified period of time.
Period Long No 10

The sampling period. Unit: minutes. Valid values: 1, 5, and 10.

Response parameters

Parameter Type Example Description
Data Struct

The returned data set.

Records Array of StatsDataDo

The data set that includes more detailed information.

StatsDataDo
X Long 1570852800000

The X axis. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

Y Float 0

The Y axis, which represents the TPS or the total number of messages written into the topic.

Title String MQ_INST_111111111111_DOxxxxxx%test trend chart of total messages written

The name of the table.

XUnit String time

The time in the X axis. The time is displayed in the UNIX timestamp format. Unit: milliseconds.

YUnit String msg

The unit of the Y axis.

RequestId String E213AD8A-0730-4B3D-A35A-340DA47D****

The ID of the request, which is a common parameter. Each request has a unique ID to facilitate troubleshooting and fault locating.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/? Action=OnsTrendTopicInputTps
&BeginTime=1570852800000
&EndTime=1570868400000
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&Topic=test
&Type=0
&<Common request parameters>

Sample success responses

XML format

<OnsTrendTopicInputTpsResponse>
  <Data>
        <Records>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570852800000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570853400000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570854000000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570854600000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570860600000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570861200000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570861800000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570862400000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570863000000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570863600000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570864200000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>1</Y>
                    <X>1570864800000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570865400000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570866000000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570866600000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570867200000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570867800000</X>
              </StatsDataDo>
              <StatsDataDo>
                    <Y>0</Y>
                    <X>1570868400000</X>
              </StatsDataDo>
        </Records>
        <XUnit>time</XUnit>
        <YUnit>msg</YUnit>
        <Title>MQ_INST_111111111111_DOxxxxxx%test-mq_topic trend chart of total messages written</Title>
  </Data>
  <RequestId>E213AD8A-0730-4B3D-A35A-340DA47D****</RequestId>
</OnsTrendTopicInputTpsResponse>

JSON format

{
    "Data": {
        "Records": {
            "StatsDataDo": [
                {
                    "Y": 0,
                    "X": 1570852800000
                },
                {
                    "Y": 0,
                    "X": 1570853400000
                },
                {
                    "Y": 0,
                    "X": 1570854000000
                },
                {
                    "Y": 0,
                    "X": 1570854600000
                },
                {
                    "Y": 0,
                    "X": 1570860600000
                },
                {
                    "Y": 0,
                    "X": 1570861200000
                },
                {
                    "Y": 0,
                    "X": 1570861800000
                },
                {
                    "Y": 0,
                    "X": 1570862400000
                },
                {
                    "Y": 0,
                    "X": 1570863000000
                },
                {
                    "Y": 0,
                    "X": 1570863600000
                },
                {
                    "Y": 0,
                    "X": 1570864200000
                },
                {
                    "Y": 1,
                    "X": 1570864800000
                },
                {
                    "Y": 0,
                    "X": 1570865400000
                },
                {
                    "Y": 0,
                    "X": 1570866000000
                },
                {
                    "Y": 0,
                    "X": 1570866600000
                },
                {
                    "Y": 0,
                    "X": 1570867200000
                },
                {
                    "Y": 0,
                    "X": 1570867800000
                },
                {
                    "Y": 0,
                    "X": 1570868400000
                }
            ]
        },
        "XUnit": "time",
        "YUnit": "msg",
        "Title": "MQ_INST_111111111111_DOxxxxxx%test trend chart of total messages written"
    },
    "RequestId": "E213AD8A-0730-4B3D-A35A-340DA47D****"
}

Error codes

For a list of error codes, visit the API Error Center.

Operations in the console

In addition to calling the OnsTrendTopicInputTps operation, you can query the statistics on produced messages in specified topics in the Message Queue for Apache RocketMQ console. For more information, see Resource reports.