Google+ Badge

Sunday, August 10, 2014

InfluxDB and Grafana Scripted Dashboards

I've been spending a lot of time lately playing with InfluxDB, using Grafana has the front-end dashboarding tool. If you haven't checked these out, you really should - they're a lot of fun and have a ton of potential.

One of the most attractive features of Grafana to me is that of "Scripted Dashboards." Basically you can write up your own semi-arbitrary JavaScript to generate a dashboard that meets almost any need you might have.

I spent some time trying to figure out how to build something fun with my InfluxDB-backed Grafana, and after some stumbling about (thanks for the pointers @torkelo!), I came up with a decent starting point!

NOTE: I are not developer - if my JS is shoddy, feel free to give me some pointers! Always happy to learn how to write better code.

You can see the code at It's basically a simple wrapper script that sources in whatever script you specify in the template URL arg. (I know, sourcing in arbitrary scripts is a major security no-no, but I'm mostly operating under the assumption that your Grafana + InfluxDB installation will be inside a properly locked-down network and used by non-malicious folks within your organization.)

If you want to know where to find various options for your panels, there a couple of places that will likely have what you seek:

  • the exported JSON representation of what you're trying to accomplish (mock it up in the GUI and export it)
  • if not in the JSON export, then in `/src/app/services/influxdb/influxdbDatasource.js`
I think there is some major potential for tools like these in "building a better metrics trap," as I like to say. Anomaly detection becomes dead simple with tools like InfluxDB, and something like scripted dashboards in Grafana lets you play with the idea of "situational dashboards" that might only show you the graphs that are relevant to some anomalous behavior in your cluster. No more 30-node nightmare dashboards, I'd hope!