www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - influxdb-dlang-wrapper v0.0.1 - D API for InfluxDB

reply Atila Neves <atila.neves gmail.com> writes:
http://code.dlang.org/packages/influxdb-dlang-wrapper

InfluxDB is a database optimised for time-series data. This 
package implements a D API via the REST interface so that this 
code works:

import influxdb;

// this will connect and create the `mydb` database if not 
already in InfluxDB
const database = Database("http://localhost:8086" /*URL*/, "mydb" 
/*DB name*/);

// no explicit timestamp
database.insert(Measurement("cpu" /*name*/, ["tag1": "foo"] 
/*tags*/, ["temperature": 42] /*values*/));
// `insert` can also take `Measurement[]` or a variadic number of 
`Measurement`s
// Measurement also has a contructor that does't take tags:
// auto m = Measurement("cpu", ["temperature": 42]);

// explicit timestamp
import std.datetime: Clock;
database.insert(Measurement("cpu", ["tag1": "foo"], 
["temperature": 68], Clock.currTime));

// this will have the two measurements given the code above
const response = database.query("SELECT * FROM cpu");

// Accessing the response.
// The code below assumes a response with one result and that 
result has only
// one series.

assert(response.results.length == 1);
const result = response.results[0];
assert(result.statement_id == 0);
assert(result.series.length == 1);
const series = result.series[0];
assert(series.rows.length == 1);
const row = series.rows[0];

assert(row.time == SysTime(DateTime(2015, 06, 11, 20, 46, 2), 
UTC()));
assert(row["foo"] == "bar");

assert(series ==
         MeasurementSeries(
             "lename", //name
             ["time", "othervalue", "tag1", "tag2", "value"], 
//column names
             //values
             [
                 ["2015-06-11T20:46:02Z", "4", "toto", "titi", 
"2"],
                 ["2017-03-14T23:15:01.06282785Z", "3", "letag", 
"othertag", "1"],
             ]
         ));
Mar 20 2017
next sibling parent Dejan Lekic <dejan.lekic gmail.com> writes:
On Monday, 20 March 2017 at 19:57:03 UTC, Atila Neves wrote:
 http://code.dlang.org/packages/influxdb-dlang-wrapper

 InfluxDB is a database optimised for time-series data. This 
 package implements a D API via the REST interface so that this 
 code works:
Brilliant! I may actually need it soon! (if they let me use D for a project we are about to start working on)
Mar 21 2017
prev sibling next sibling parent reply Andy smith <andyrsmith gmail.com> writes:
On Monday, 20 March 2017 at 19:57:03 UTC, Atila Neves wrote:
 http://code.dlang.org/packages/influxdb-dlang-wrapper

 InfluxDB is a database optimised for time-series data. This 
 package implements a D API via the REST interface so that this 
 code works:

 [...]
Cool stuff. Worth stating that one of the big wins here is that the very cool 'grafana' metrics/dashboard web abb talks seamlessly to influx dub. So if you can get your data into influx you get a pretty cool metrics visualisation system for free, ( well, for a small time investment setting it up :-) ). Cheers, A
Apr 09 2017
parent Atila Neves <atila.neves gmail.com> writes:
On Sunday, 9 April 2017 at 08:18:38 UTC, Andy smith wrote:
 On Monday, 20 March 2017 at 19:57:03 UTC, Atila Neves wrote:
 http://code.dlang.org/packages/influxdb-dlang-wrapper

 InfluxDB is a database optimised for time-series data. This 
 package implements a D API via the REST interface so that this 
 code works:

 [...]
Cool stuff. Worth stating that one of the big wins here is that the very cool 'grafana' metrics/dashboard web abb talks seamlessly to influx dub. So if you can get your data into influx you get a pretty cool metrics visualisation system for free, ( well, for a small time investment setting it up :-) ). Cheers, A
I noticed that about grafana supporting InfluxDB, which is indeed pretty cool. On the time setting up though, it's virtually 0: https://github.com/kamon-io/docker-grafana-graphite Clone that, `make up` and click on the pretty web controls. :) Atila
Apr 09 2017
prev sibling parent Atila Neves <atila.neves gmail.com> writes:
On Monday, 20 March 2017 at 19:57:03 UTC, Atila Neves wrote:
 http://code.dlang.org/packages/influxdb-dlang-wrapper

 InfluxDB is a database optimised for time-series data. This 
 package implements a D API via the REST interface so that this 
 code works:

 [...]
Renamed to influx-d Atila
Apr 21 2017