Best way to collect logs from the hub?


(CRL) #1

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


Pushing Smartthings Events to remote syslog/TCP port?
Zwave Power Strip from AEON
Collect logs to external database?
#2

Ditto! Anyone creating a log export / capture?

Thanks all,

-B


(Ron S) #3

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.


(Freddy) #4

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


(Kris Linquist) #5

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…


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #6

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.


(The fish is still dead.) #7

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


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #8

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.


(Rob Landry) #9

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.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #10

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


(The fish is still dead.) #11

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.


(mikenicholson) #12

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


(The fish is still dead.) #13

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


(Brian) #14

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…


#15

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.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #16

and


(Brian) #17

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?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #18

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.


(Brian) #19

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.


(The fish is still dead.) #20

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: