You can call this operation to query the number of sent and received messages based on information such as topics.
Scenarios
OnsMqttQueryMsgTransTrend is typically used to generate data reports and service statistics.
Limits
API operations are designed for you to implement custom management and development. Based on this, the Message Queue for MQTT broker throttles frequent calls that amount to 30 or more per minute. Therefore, do not call this operation in the main service process. To determine whether a Message Queue for MQTT client is connected, use the device online/offline notification function. If a Message Queue for MQTT client is online, this client has been connected to a Message Queue for MQTT broker.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | OnsMqttQueryMsgTransTrend |
The operation that you want to perform. Set the value to OnsMqttQueryMsgTransTrend. |
BeginTime | Long | Yes | 1570957261 |
The beginning of the time range to query. |
EndTime | Long | Yes | 1570962601 |
The end of the time range to query. We recommend that the start time and end time of a query fall on the same day. If the time range for a query exceeds this time limit, the backend automatically returns query results that only correspond to this time limit. |
InstanceId | String | Yes | post-cn-0pp12gl**** |
The ID of the Message Queue for MQTT instance whose statistics you want to query. This parameter is required for instances with separate namespaces. |
ParentTopic | String | Yes | test |
The parent topic that you want to query. |
TpsType | String | Yes | TPS |
Specifies whether to query the TPS or SUM. Valid values:
Other values are invalid. |
TransType | String | Yes | PUB |
Specifies whether to query the production or consumption report. Valid values:
Other values are invalid. |
SubTopic | String | No | /testMq4Iot |
The subtopic that you want to query. This parameter can be blank if no subtopic exists or if you want to query all the information about the parent topic. |
MsgType | String | No | P2P |
The message type. Valid values:
By default, all messages are queried if this parameter is not set. Other values are invalid. |
Qos | Integer | No | 0 |
The quality of service (QoS) level of the messages to be queried. Valid values:
By default, all messages are queried if this parameter is set to other values or is not set. For more information about QoS, see Terms. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Data | Struct |
The returned data set. |
|
Records | Array |
The data set that includes more detailed information. |
|
StatsDataDo | |||
X | Long | 1570960800 |
The X axis, which represents time in the timestamp format. Unit: millisecond. |
Y | Float | 3 |
The Y axis, which represents the TPS or the message production volume. |
Title | String | Message production TPS |
The name of the table that lists the historical message production TPS or volume in the specified time range. |
XUnit | String | Time |
The time in the X axis, which is in the timestamp format. Unit: millisecond. |
YUnit | String | Messages/second |
The unit of the Y axis. |
RequestId | String | 77B5727C-CCDF-4404-B7A0-EC0D3CF4BEDE |
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)://[Endpoint]/? Action=OnsMqttQueryMsgTransTrend
&BeginTime=1570957261
&EndTime=1570962601
&ParentTopic=test
&TpsType=TPS
&TransType=PUB
&SubTopic=/testMq4Iot
&MsgType=P2P
&Qos=0
&InstanceId=post-cn-0pp12gl****
&<Common request parameters>
Sample success responses
XML
format
<OnsMqttQueryMsgTransTrendResponse>
<Data>
<Records>
<StatsDataDo>
<X>1570960800</X>
<Y>3</Y>
</StatsDataDo>
</Records>
<XUnit>Time</XUnit>
<YUnit>Messages/second</YUnit>
<Title>Message production TPS</Title>
</Data>
<RequestId>77B5727C-CCDF-4404-B7A0-EC0D3CF4BEDE</RequestId>
</OnsMqttQueryMsgTransTrendResponse>
JSON
format
{
"Data": {
"Records": {
"StatsDataDo": [{"X": "1570960800",
"Y": "3"}]
},
"XUnit": "Time",
"YUnit": "Messages/second",
"Title": "Message production TPS"
},
"RequestId": "77B5727C-CCDF-4404-B7A0-EC0D3CF4BEDE"
}
Error codes
For a list of error codes, visit the API Error Center.