Query "last connected" time via management api


I have a question/feature request: I would like to be able to query the “last connected timestamp” that is visible on the hosted mender website, is that possible? I see that there is a way to get the current connection status of the unit: Mender API docs

To do this on my own I feel like I would:

  • query that “connected” status on a set time interval
  • add the connected status to a DB
  • to get the last connected time I would then query the database for the most recent time the device was connected

I feel that doing this over a whole fleet of devices isn’t the best way to accomplish this task. Is there a better way to get the “last connected time”? I do notice there is also a time stamp for when the inventory for a device was last updated, maybe I should use that time stamp instead?

Thanks in advance for any help!


Hi Matt,

I think you are looking for the “devices” endpoint: Mender API docs

For example, if you try with the following endpoint, you will receive the list of all the devices:

You are looking for the “updated_ts” property. It will contain the last the device reported that it was connected.

Hope it helps :slight_smile:

Thanks Luis, I will use the updated_ts value for the last connected indicator. This issue is solved and can be closed. Much appreciated!