NAME
ETL::Yertl::Adapter::influxdb - Adapter to read/write from InfluxDB time series database
VERSION
version 0.044
SYNOPSIS
my $db = ETL::Yertl::Adapter::influxdb->new( 'influxdb://localhost:8086' );
my @points = $db->read_ts( { metric => 'db.cpu_load.1m' } );
$db->write_ts( { metric => 'db.cpu_load.1m', value => 1.23 } );
DESCRIPTION
This class allows Yertl to read and write time series from the InfluxDB time series database.
This adapter is used by the yts command.
Metric Name Format
InfluxDB has databases, metrics, and fields. In Yertl, the time series is identified by joining the database, metric, and field with periods (.
). The field is optional, and defaults to value
.
# Database "foo", metric "bar", field "baz"
yts influxdb://localhost foo.bar.baz
# Database "foo", metric "bar", field "value"
yts influxdb://localhost foo.bar
METHODS
new
my $db = ETL::Yertl::Adapter::influxdb->new( 'influxdb://localhost' );
my $db = ETL::Yertl::Adapter::influxdb->new( 'influxdb://localhost:8086' );
Construct a new InfluxDB adapter for the database on the given host and port. Port is optional and defaults to 8086
.
read_ts
my @points = $db->read_ts( $query );
Read a time series from the database. $query
is a hash reference with the following keys:
- metric
-
The time series to read. For InfluxDB, this is the database, metric, and field separated by dots (
.
). Field defaults tovalue
. - start
-
An ISO8601 date/time for the start of the series points to return, inclusive.
- end
-
An ISO8601 date/time for the end of the series points to return, inclusive.
-
An optional hashref of tags. If specified, only points matching all of these tags will be returned.
write_ts
$db->write_ts( @points );
Write time series points to the database. @points
is an array of hashrefs with the following keys:
- metric
-
The metric to write. For InfluxDB, this is the database, metric, and field separated by dots (
.
). Field defaults tovalue
. - timestamp
-
An ISO8601 timestamp or UNIX epoch time. Optional. Defaults to the current time.
- value
-
The metric value.
SEE ALSO
ETL::Yertl, yts, Reading data from InfluxDB, Writing data to InfluxDB, InfluxDB Query language
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.