Viewing disconnected MQTT client-related statistics by using REST Monitoring APIs

System administrators can view disconnected MQTT client-related statistics by using a REST Monitoring API.

About this task

System administrators can view disconnected MQTT client-related statistics by using a REST Monitoring API, or by using the IBM® Watson IoT Platform - Message Gateway Web UI. For more information about using the IBM Watson IoT Platform - Message Gateway Web UI to view disconnected MQTT client-related statistics, see Viewing MQTT client-related statistics by using the GUI.

Procedure

MQTT client-related monitoring statistics can be created by using a REST Monitoring API. To create MQTT client-related monitoring statistics, complete the following steps:

  1. Use the IBM Watson IoT Platform - Message Gateway REST API GET method with the following IBM Watson IoT Platform - Message Gateway configuration URI:

    http://<admin-endpoint-IP:Port>/ima/v1/monitor/<Object Type>

  2. Provide query parameters requesting the statistics that you want returned in the JSON payload. The following example uses cURL to create MQTT client-related statistics:
    curl -X GET http://127.0.0.1:9089/ima/v1/monitor/MQTTClient?ClientID=ClientID%26StatType=StatType%26ConnectionState=&ConnectionState%26ResultCount=ResultCount

    Where:

    • ClientID
      Optional.

      Specifies the name of the MQTT Client.

      Asterisk (*) matches 0 or more characters. To use an asterisk (*), you must specify ClientID in the query.

      The default value is *.

    • ResultCount
      Optional.

      Specifies the number of results to display.

      Options available for selection are 10, 25, 50, and 100.

      The default is 25.

    • &ConnectionState
      Optional.

      Lists connected clients, or both connected and disconnected clients.

      This value can be one of the following values:
      • Connected
        Lists clients that are connected to IBM Watson IoT Platform - Message Gateway.
      • All
        Lists all clients, whether they are disconnected, or connected to IBM Watson IoT Platform - Message Gateway.
    • StatType
      Optional.

      Specifies the type of data to order the results by.

      This value can be the following values:
      • LastConnectedTimeOldest
        The most recent date that the specified client ID connected to IBM Watson IoT Platform - Message Gateway.
      • AllUnsorted
        Lists all MQTT client IDs that are connected to IBM Watson IoT Platform - Message Gateway.
        Any value that is specified for ResultCount is ignored, so setting StatType to AllUnsorted can result in a large number of responses being generated.

      The default value is LastConnectedTimeOldest.

Results

The following fields are returned:
  • ClientID
    String
    The Client ID.
  • IsConnected
    Boolean
    Whether the client is connected to the IBM Watson IoT Platform - Message Gateway server. Only disconnected clients are shown.
  • LastConnectedTime
    Numeric
    Specifies the number of microseconds since the client last connected to the IBM Watson IoT Platform - Message Gateway server.

Example

The following example uses cURL to show how a GET method is used to create statistics about a disconnected MQTT Client with a Client ID that is set to DemoClientID:

curl -X GET http://127.0.0.1:9089/ima/v1/monitor/MQTTClient?ClientID=DemoClientID
 
 

The following example shows a successful example response to the GET method that was used to create statistics about a disconnected MQTT Client with a Client ID that is set to DemoClientID:

{ "Version":"v1", "MQTTClient": [ { "ClientID":"DemoClientID","IsConnected":False,"LastConnectedTime":1446728129213566618 } ] }