InfluxDB - Client library for InfluxDB
use InfluxDB; my $ix = InfluxDB->new( host => '127.0.0.1', port => 8086, username => 'scott', password => 'tiger', database => 'test', ); $ix->write_points( data => { name => "cpu", columns => [qw(sys user idle)], points => [ [20, 50, 30], [30, 60, 10], ], }, ) or die "write_points: " . $ix->errstr; my $rs = $ix->query( q => 'select * from cpu', time_precision => 's', ) or die "query: " . $ix->errstr}; # $rs is ArrayRef[HashRef]: # [ # { # columns => ["time","sequence_number","idle","sys","user"], # name => "cpu", # points => [ # ["1391743908",6500001,10,30,60], # ["1391743908",6490001,30,20,50], # ], # }, # ] my $hrs = $ix->as_hash($rs); # or InfluxDB->as_hash($rs); # convert into HashRef for convenience # { # cpu => [ # { # idle => 10, # seqnum => 6500001, # sys => 30, # time => "1391743908", # user => 60 # }, # { # idle => 30, # seqnum => 6490001, # sys => 20, # time => "1391743908", # user => 50 # } # ] # }
InfluxDB is a client library for InfluxDB <http://influxdb.org>.
**************************** CAUTION **************************** InfluxDB that is a time series database is still in development status, so this module is also alpha state. Any API will change without notice. *****************************************************************
Creates and returns a new InfluxDB client instance. Dies on errors.
%args is following:
Write to multiple time series names.
HashRef like following:
{ name => "name_of_series", columns => ["col1", "col2", ...], points => [ [10.0, 20.0, ...], [10.9, 21.3, ...], ... ], }
The precision timestamps should come back in. Valid options are s for seconds, m for milliseconds, and u for microseconds.
The InfluxDB query language, see: http://influxdb.org/docs/query_language/
Chunked response.
Utility instance/class method for handling result of query.
Takes result of query()(ArrayRef) and convert into following HashRef.
query()
{ cpu => [ { idle => 10, seqnum => 6500001, sys => 30, time => "1391743908", user => 60 }, { idle => 30, seqnum => 6490001, sys => 20, time => "1391743908", user => 50 } ] }
Switch to another database.
Change your user-context.
Create database. Requires cluster-admin privileges.
List database. Requires cluster-admin privileges.
[ { name => "databasename", replicationFactor => 1 }, ... ]
Delete database. Requires cluster-admin privileges.
Returns status of previous request, as following hash:
HTTP status code.
HTTP status message.
HTTP status line (code . " " . message).
Response body.
Returns error message if previous query was failed.
Returns hostname of InfluxDB server.
Returns port number of InfluxDB server.
Returns current user name.
Returns current database name.
Print debug messages to STDERR.
HIROSE Masaaki <hirose31@gmail.com>
https://github.com/hirose31/p5-InfluxDB
git clone https://github.com/hirose31/p5-InfluxDB.git
patches and collaborators are welcome.
http://influxdb.org
Copyright HIROSE Masaaki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install InfluxDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm InfluxDB
CPAN shell
perl -MCPAN -e shell install InfluxDB
For more information on module installation, please visit the detailed CPAN module installation guide.