MorphiumDriver implementation for InfluxDB
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

InfluxDB Driver for Morphium 3.x

This is an implementation of the MorphiumDriver interface in the morphium project.

Morphium was built to be a mongodb abstraction layer and driver. With Version 3.0 a new Driver architecture was introduced, making morphium able to work with theoretically any kind of database.

InfluxDB is a time series db which is something very different to mongodb and does not have a complex ql like a full blown SQL-DB.

Of course, using this driver will have some drawbacks, you will not be able to do everything, you could do with the CLI or a native driver.


  • send timeseries data to influxdb in an efficient and "known" way utelizing all the good stuff, morphium does offer (bulk requests etc)
  • simple cluster support
  • do simple queries to influx, gathering high level information

what this driver will not do:

  • help you visualizing things
  • administration of influxdb

How To

quite simple. Instanciate Morphium as usual, just set a different driver:

        MorphiumConfig cfg = new MorphiumConfig("graphite", 100, 1000, 10000);

        cfg.setLogLevelForClass(InfluxDbDriver.class, 5);
        Morphium m = new Morphium(cfg);

Sending Data do influx works same as if it was a mongodb:

            EntTest e = new EntTest();
            //fill with data ...            

reading from influx works also similar to mongodb, with minor changes:

  Query<EntTest> q=m.createQueryFor(EntTest.class).f("host").eq(hosts[0]).f("lfd").gt(12);
        q.addProjection("ret_code","group by");
        List<EntTest> lst=q.asList();
        System.out.println("Got results:"+lst.size());

you need to set the aggregation method as projection operator. Also the group by clause is modeled ther.

And one major hack: if you want to do queries using time constraints like where time > now() - 10d you need to query using time()as morphium needs to detect that this is not a field but a function you're calling:

 q=m.createQueryFor(EntTest.class).f("host").eq(hosts[1]).f("lfd").gt(12).f("time()").gt("now() - 100d");
        q.addProjection("ret_code","group by");