Hello Team,
I have a question about the "mqtt_retained_storage" returned by the "/platform/customer/statistics" API. Does it return the size of the total retained messages? Is the value returned in MB or KB?
I tried calling the following API to get all the retained messages, but it returned an empty array, but the "mqtt_retained_storage" returned seems to be always greater than zero.
mqtt_retained_storage
Hello.
mqtt_retained_storage parameter is stored in KB. Yes it's total retained messages.
To get all retained messages by rest api call you can use this curl command:
curl -X GET --header 'Accept: application/json' --header 'Authorization: FlespiToken XXXXXXXXXXXXXXXXXXXXX' 'https://flespi.io/mqtt/messages/%23'
Just replace XXXXXX with your token.
dexif The sizes returned by the two APIs are not matching.
The following returned 10772 KB
But the call to get the retained messages only returned 11.95KB
Also, most of the data returned are for "flespi/state" topic, is it normal for the "mqtt_retained_storage" to go up when MQTT traffic is high?
Thanks for the reply dexif . My concern is that the "/mqtt/messages/%23" call only reported 11.95KB (including HTTP headers), but the "mqtt_retained_storage" is reporting 10772 KB, which is way more than 11.95KB reported by "/mqtt/messages/%23". So I was wondering where the rest of the retained storage is coming from. Just trying to understand how this works so that we can keep the value in check.
OK. I will try to explain that. Each message in flespi takes at least 1kb (storage page size). The namespace "flespi/state/#" is also included when calculating the storage. "state" also contains records of mqtt sessions. Each mqtt connection generates stored messages (for sessions). If your devices / services generate a lot of reconnections - this will add some storage usage. Moreover, if you delete messages - they will still occupy the storage until the garbage collector is called (once a day).
Thanks for the explanation. That makes sense.