Best way to collect logs from the hub?

Hi SmartThings developers,

I know there is no a data exporting tool supported by SmartThings. Do you have any suggestions to harvest logs/events from a hub so that I can do some data analysis? Your answer will help me greatly.

Best,
Joey

5 Likes

Ditto! Anyone creating a log export / capture?

Thanks all,

-B

I am doing it physically here in Jersey! Have to get the fireplace going… It’s far below negative with the wind chill… :slight_smile: logs help.

I’m looking to solve the same problem of analysing how often my heater is on.
Any solution to data logging?

If you have somewhere that you can run a web server/nodejs script/php file/etc., you can use a smartapp to subscribe to events, then when an event occurs, make an HTTP GET/POST to your server and run the analytics there…

1 Like

Fetch recent events with: https://graph.api.smartthings.com/api/accounts/idHashString/events

Fetch lots (999…) of events with: https://graph.api.smartthings.com/api/accounts/idHashString/events?max=999

Get idHashString after logging into the API and running:

https://graph.api.smartthings.com/api/accounts

…CP / Terry.

8 Likes

Is there documentation on this somewhere? I’m having a tough time finding it on the docs site.

I was hoping someone would ask that question!

There used to be a “work-in-progress” PDF / Google Doc that had details on a lot of the REST-API endpoints, but it disappeared, and the replacement documentation doesn’t seem to go into that area of detail … unless I am also missing some obvious link. Search of docs didn’t yield result.

@Jim or @Ben or @urman?

I would expect it to be linked from here:
http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/index.html

Or here: http://docs.smartthings.com/en/latest/reference-material.html

But, in the meantime, someone made an unofficial copy here:

…CP / Terry.

1 Like

Just curious if this still works. I think i read on the forums that the new oauth flow made this method obsolete. I am trying to pull video feeds from the hub events but having little luck getting the hub events to display.

It still works for me; though the various official alternative methods are worth looking into.

I’ve been using a SmartApp I wrote to subscribe to all of my devices and ship the events off to a Logstash server, using Kibana as the front-end. This gets me all of the historical data I want and the ability to make pretty pictures out of it as well.

4 Likes

The links are broken 404 error. Was it removed on purpose?

Nope, just broke during a repo re-org. The link above should work now.

1 Like

Anyone know of a cloud version of Logstash functionality? I’m hoping to inspire, or be inspired to create a cloud logger for the community to catch recent poltergeist issues.

I’m open to other methods as well, I realize you could leave the logger open in ST, but it’s hard to keep that up for history (and it crashes a fair bit lately). You could probably also send debug as an event, or as texts, but I feel like that might punish the platform, and cause unnecessary load.

Some quick research:


https://www.loggly.com/
https://papertrailapp.com/
Will add more as time allows…

Has anyone wrote a SmartApp logger through the SmartThings Web Services directly? It could interface with pretty much any server side language or database of choice.

and

1 Like

I use initial state, but it’s data oriented, not log oriented. I believe Thinglayer is the same (tried it out too before…).

Maybe I’m missing a functionality?

1 Like

Ohhhhh…

What logs are you trying to capture … the output of Live Logging, or the output of Events?

Not sure if there is any way to continuously stream Live Logging to a collection service. Perhaps some clever Javascript to scrape the output.

As for Events, the two example services can (theoretically?) capture all Events, not just State changes and Value reporting. Message Events are just text values + “descriptionText”, after all.

I’ve seen a couple of cases where if I could go back a day in live logging, I’d be able to tell what happened.

Even if I had to put lines in code, it would be useful as a trace.

1 Like

I’m using Logstash on one of my own servers to do this. In any SmartApp where I need to retain history, I add the following method and use it to log messages instead of log.debug():

I also wrote another SmartApp that subscribes to all of my things and logs their events to the same Logstash server for easier correlation with the log entries:

3 Likes