InfluxDB - Client library for InfluxDB
The JSON write protocol is deprecated as of InfluxDB 0.9.1. It is still present but it will be removed when InfluxDB 1.0 is released. The line protocol is the primary write protocol for InfluxDB 0.9.1+.
This InfluxDB module can handle only JSON protocol.
If you want to use line protocol, please use InfluxDB::LineProtocol module.
use InfluxDB; my $ix = InfluxDB->new( host => '127.0.0.1', port => 8086, username => 'scott', password => 'tiger', database => 'test', # ssl => 1, # enable SSL/TLS access # timeout => 5, # set timeout to 5 seconds ); $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 # } # ] # }
This module `InfluxDB` is a client library for InfluxDB <http://influxdb.org>.
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 time and any other data fields which should be graphable must be numbers, not text. See "simple scalars" in JSON.
time
The precision timestamps should come back in. Valid options are s for seconds, m for milliseconds, and u for microseconds.
Delete ALL DATA from series specified by name
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 } ] }
Create continuous query.
$ix->create_continuous_query( q => "select mean(sys) as sys, mean(usr) as usr from cpu group by time(15m)", name => "cpu.15m", );
List continuous queries.
Delete continuous query that has specified id.
You can get id of continuous query by list_continuous_queries().
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.
List series in current database
Create a database user on current database.
Delete a database user on current database.
Update a database user on current database.
List all database users on current database.
Show a database user on current database.
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.