I fell asleep on a train with an empty head. The train made a stop and I woke up, my head filled with an idea and some kind of mad inspiration to follow it through: it was time to move the home metrics stuff out of the old netbook and into the cloud.
The 1.0 setup has served well for over 3 years now, without hardly any interventions. In fact, this all started some 5 years ago(!). TL;DR I’m sending sensor metrics using Node.js to a dashboard based on the time series database Graphite. Kill your darlings and welcome to the age of cloud!
Hosted Graphite packs Graphite with Grafana to visualise metrics stored in the time series database. Hosted Graphite is available as a Heroku add-on which makes this switch a very smooth and convenient cloud experience.
App names blurred to make it look more interesting.
I created 3 apps on Heroku: one to hold the Hosted Graphite add-on and two others to serve up metrics from Eliq and Telldus respectively. With Hosted Graphite you need to prepend an API key when sending metrics to Graphite, and Heroku (being https://12factor.net/ compliant) uses environment variables, so I had to update eliq2graphite and telldus2graphite and their dependencies to accommodate this.
Deployment to Heroku is just a matter of pushing code from git:
# setup heroku git:remote -a <app-name>
# deploy git push heroku master
The scripts are executed periodically using the Heroku Scheduler add-on:
Logs can be read with the “heroku logs” command:
heroku logs -a <app-name>
heroku[scheduler.3876]: Starting process with command `node bin/telldus2graphite.js` heroku[scheduler.3876]: State changed from starting to up app[scheduler.3876]: Logged: ["home.chili.temp 10.9 1519109556\n"] app[scheduler.3876]: Logged: ["home.outdoor.temp -4.7 1519109628\n","home.outdoor.humidity 83 1519109628\n"] app[scheduler.3876]: Logged: ["home.rain.rrate 0 1519109525\n","home.rain.rtot 206.3 1519109525\n"] app[scheduler.3876]: Logged: ["home.uv.uv 0 1519109343\n"] app[scheduler.3876]: Logged: ["home.wind.wdir 292.5 1519109799\n","home.wind.wavg 0 1519109799\n","home.wind.wgust 0 1519109799\n"] heroku[scheduler.3876]: Process exited with status 0 heroku[scheduler.3876]: State changed from up to complete
Value mapping, colored thresholds, and units are some of Grafana’s many features.
Oh, I forgot to mention, this setup is completely free. Free as in free 🍺 #winning
Update: Actually it’s $29/mo for Grafana after the free trial 😬
To be continued 😀 …