For a long time now graphite has been the defacto standard for use as a time-series database, recently I decided to try InfluxDB, this blog post is about what I’ve found.
Installation and configuration of InfluxDB is as about as simple as it can get:
Two binaries (client and daemon), init configuration, a configuration file, and a changelog. Great!
The out of the box configuration is good enough to get going with, however, InfluxDB has various listeners that enable the use of more primitive metric protocols such as graphite and collectd. I enabled the graphite listener:
Then configured carbon-relay-ng to relay metrics to InfluxDB:
With metrics now being relayed into InfluxDB it’s time to create some queries:
But wait a minute, isn’t this supposed to be a columnar database?
Reading more of the docs shows I need to add a template to graphite so that the graphite data can be converted into tagged data, my graphite config now looks like this:
This time I manually run the check from my local machine to generate some data:
Check the data in InfluxDB:
This looks better but the query shows that each metric is being written to the database as its own measurement with a single column called value. The host and interface columns here are infact tags, rather than fields.
Lets enable the udp listener and write some data to the database using InfluxDBs native line protocol.
influxdb.conf:
This is what we want, data stored in named fields.
It turns out that with the original storage engine BZ1 it’s not only inefficient to do lookups on multiple field data, it’s also not possible to add fields to a metric once it’s been written to.
Fortunately I had some luck as the InfluxDB team were about to release their new storage engine entitled TSM1. The new storage engine allows fields to be added to existing metrics in a database.
My patch to enable a special keyword field has been merged into master and will be part of the 0.9.5 release. For now it’s possible to use a nightly build.
From a clean system, to get columnar graphite data in InfluxDB, do the following:
Install nightly (or >= 0.9.5) InfluxDB build:
Enable graphite listener with templates for each of your metrics, including special field keyword: