Assure1::InfluxDB::Client library¶
Description¶
Assure1::InfluxDB::Client allows you to interact with the InfluxDB HTTP API. The module essentially provides
one method per InfluxDB HTTP API endpoint, that is ping
, write
and query
.
Based on InfluxDB::HTTP.
Synopsis¶
use Assure1::InfluxDB::Client;
my $influx = Assure1::InfluxDB::Client->new();
my $pingResult = $influx->ping();
print "$pingResult\\n";
my $query = $influx->query(
\['SELECT Lookups FROM \_internal.monitor.runtime WHERE time > ' . (time - 60) \* 1000000000, 'SHOW DATABASES'\],
epoch => 's'
);
print Dumper($query);
Methods¶
error¶
Return the last error
ping¶
Pings the InfluxDB instance configured in the constructor (i.e. by host
and port
).
Returned object evaluates to true or false depending on whether the ping was successful or not.
If true, then it contains a version
attribute that indicates the InfluxDB version running on
the pinged server.
The version
attribute is extracted from the X-Influxdb-Version
HTTP response header, which
is part of the HTTP response from the pinged InfluxDB instance.
Synopsis
my $ping = $influx->ping();
print $ping->version if ($ping);
query¶
Used to query the InfluxDB instance. All parameters but the first one are optional. The
query
parameter can either be a String or a Perl ArrayRef of Strings, where every String
contains a valid InfluxDB query.
If the returned object evaluates to true, indicating that the query was successful, then
the returned object's data
attribute contains the entire response from InfluxDB as Perl
hash. Additionally the attribute request_id
provides the request identifier as set in
the HTTP reponse headers by InfluxDB. This can for example be useful for correlating
requests with log files.
query($query, database => "DATABASE", chunk_size => CHUNK_SIZE, epoch => "EPOCH")
write¶
Writes data into InfluxDB. The parameter measurement
can either be a String or an
ArrayRef of Strings, where each String contains one valid InfluxDB LineProtocol
statement. All of those mesaurements are then sent to InfluxDB and the specified
database. The returned object evaluates to true if the write was successful, and otherwise
to false.
The optional argument precision can be given if a precision different than "ns" is used in the line protocol. InfluxDB docs suggest that using a coarser precision than ns can save space and processing. In many cases "s" or "m" might do.
The optional argument retention_policy can be used to specify a retention policy other than the default retention policy of the selected database.
write($measurement, database => "DATABASE", precision => "PRECISION", retention_policy => "RP")