Statistics for a device

Do you have any idea how to get specific statistics for a device from WebThings gateway?
ex: How long device was turned on in total?

If you enable the Logs experiment through Settings, you can log any device property you want, for your desired amount of time. With that knowledge, you can probably do whatever analytics you want.

I’ve noticed that I can track on/of statistic through Log experiment. I need to pro!cess these statistics. I have few additional questions related to it:

  1. Whats is the architecture behind ‘Log experiment’? Any database where these data are stored on pi?
  2. Is it possible to get these data via REST API?

My goal is to get this data - process if needed and present in another dashboard.

As I did some research, I would need some confirmation from experts for the folowing hypotesis:
Experiment logs graphs are created by parsing log files located in /home/pi/.mozilla-iot/log

Is it true?

Don’t get too hung up on the “experiment” part. That just means it is something we’ve been testing that wasn’t quite ready to be enabled by default. That’s changing with 0.11, as it’s no longer behind an experimental flag.

The data points all get stored in ~/.mozilla-iot/log/logs.sqlite3.

They are accessible via the REST API, but only with a user JWT, not with an OAuth token.

Hi Michael,

Thank you for this suggestion it works for me fine.
As I need to use sqlite3 db entries may I ask you how to stop totally logs generation in this dir ~/.mozilla-iot/log/ to save SD card disk space?

Are you talking about the gateway’s log files, e.g. run-app.log.*? If you really want to do that, you’d probably just need to remove this block of code. However, the total size of log files is capped at about 100 MB, so they’re not going to take up a significant amount of space.