Query the mqtt_stats table

Example querying the mqtt_stats table

Use the getRecordsByIndex action to retrieve the cursor

Request

{
  "action": "getRecordsByIndex",
  "params": {
    "tableName": "mqtt_stats",
    "indexName": "mqtt_stats_ts",
    "returnCursor": true
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
 
 

Response

{
  "authToken": "replaceWithAuthTokenFromCreateSession",
  "result": {
    "cursorId": "replaceWithCursorIdFromGetRecords",
    "totalRecordCount": 34620
  },
  "debugInfo": {
    "request": {
      "authToken": "replaceWithAuthTokenFromCreateSession",
      "action": "getRecordsByIndex",
      "params": {
        "tableName": "mqtt_stats",
        "indexName": "mqtt_stats_ts",
        "returnCursor": true
      },
      "debug": "max"
    },
    "serverSuppliedValues": {
      "databaseName": "faircom",
      "ownerName": "admin"
    },
    "errorData": {
      "errorData": null
    },
    "warnings": []
  },
  "errorCode": 0,
  "errorMessage": ""
}
 
 

Use the cursor from the getRecordsByIndex action in the getRecordsFromCursor action to query the mqtt_stats table

Request

{
  "action": "getRecordsFromCursor",
  "params": {
    "cursorId": "replaceWithCursorIdFromGetRecords",
    "fetchRecords": 1
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
 
 

Response

{
  "authToken": "replaceWithAuthTokenFromCreateSession",
  "result": {
    "dataFormat": "objects",
    "binaryFormat": "hex",
    "variantFormat": "json",
    "stringFormat": "json",
    "fixedLengthCharFormat": "sql",
    "includeBookmarks": false,
    "fields": [
      {
        "name": "id",
        "type": "bigint",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 1,
        "autoValue": "incrementOnInsert"
      },
      {
        "name": "stat_ts",
        "type": "timestamp",
        "length": null,
        "scale": 3,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "timestampOnInsert"
      },
      {
        "name": "connect_count",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      },
      {
        "name": "disconnect_count",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      },
      {
        "name": "topic_count",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      },
      {
        "name": "subscription_count",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      },
      {
        "name": "retained_msg_count",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      },
      {
        "name": "inbound_msg_per_second_avg",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      },
      {
        "name": "outbound_msg_per_second_avg",
        "type": "integer",
        "length": null,
        "scale": null,
        "defaultValue": null,
        "nullable": false,
        "primaryKey": 0,
        "autoValue": "none"
      }
    ],
    "data": [
      {
        "connect_count": 16,
        "disconnect_count": 3,
        "id": 35480,
        "inbound_msg_per_second_avg": 7,
        "outbound_msg_per_second_avg": 7,
        "retained_msg_count": 234,
        "stat_ts": "2026-06-17T19:31:50.291000000",
        "subscription_count": 948,
        "topic_count": 1199
      }
    ],
    "primaryKeyFields": [
      "id"
    ],
    "changeIdField": null,
    "moreRecords": true,
    "requestedRecordCount": 1,
    "returnedRecordCount": 1
  },
  "debugInfo": {
    "request": {
      "authToken": "replaceWithAuthTokenFromCreateSession",
      "action": "getRecordsFromCursor",
      "params": {
        "cursorId": "replaceWithCursorIdFromGetRecords",
        "fetchRecords": -1
      },
      "debug": "max"
    },
    "serverSuppliedValues": {
      "databaseName": null,
      "ownerName": null
    },
    "errorData": {
      "errorData": null
    },
    "warnings": []
  },
  "errorCode": 0,
  "errorMessage": ""
}
 
 

 

mqtt_stats table field descriptions

Field Description coltype
id The id of the table bigint
stats_ts Date and time when the stat was collected timestamp
connection_count Number of MQTT connects. integer
disconnect_count Number of MQTT disconnects. integer
topic_count Number of topics.  integer
subscription_count Number of subscriptions.  integer
retained_msg_count Number of retained messages. integer
inbound_msg_per_second_avg Average number of messages published per second. integer
outbound_msg_per_second_avg Average number of messages forwarded to the subscribers per second. integer