NAME

InfluxDB::Client::DataSet - simple container to hold and prepare data for InfluxDB::Client-write()>

VERSION

version 0.1

SYNOPSIS

use InfluxDB::Client;
use InfluxDB::Client::DataSet;

my $dataset1 = InfluxDB::Client::DataSet->new('measurement');
$dataset1->value(cost => 42, funfactor => 1000);
$dataset1->value(available => 3);
$dataset1->tag(tag => 'wanted');

# does the same as above, but in one call
my $dataset2 = InfluxDB::Client::DataSet->new(
    measurement => 'measurement',
    values => {
        cost        => 42,
        funfactor   => 1000,
        available   => 3
    },
    tags => {
        tag => 'wanted'
    }
);

METHODS

new($measurement)

creates a new, empty InfluxDB::Client::DataSet for the given measurement.

The current timestamp is saved on creation

new(%args)

creates a new InfluxDB::Client::DataSet

The arguments are:

  • measurement name of the measurement the data should be written to

  • values a hash reference of the values to write

  • tags a hash reference of the tags to write

  • precision defines the precision of the given/generated timestamp value, may be one of ns,u,ms,s,m,h. Defaults to ns

  • timestamp an integer representing the epoch in the given precision

measurement()

returns: the measurement

measurement($measurement)

Sets the measurement to $measurement

returns: the new measurement

value()

returns: a hash reference of values

value($key)

returns: the value with the given $key

value(\%values)

override the current values with the given hash reference

returns: a hash reference of values

value(%values)

sets the given values

returns: a hash reference of values

tag()

returns: a hash reference of tags

tag($key)

returns: the tag with the given $key

tag(\%tags)

override the current tags with the given hash reference

returns: a hash reference of tags

tag(%tags)

sets the given tags

returns: a hash reference of tags

precision()

returns: a precision of the dataset

ts()

returns: the timestamp of the DataSet

ts($timestamp)

sets the timestamp to $timestamp

returns: the new timestamp of the DataSet

set_ts($timestamp)

sets the timestamp to $timestamp. If the $timestamp is empty, the equivalent of now is used.

using this method is the same as $ds->ts($timestamp // $ds->get_ts);

returns: the new timestamp of the DataSet

get_ts()

returns: the current timestamp in the precision given on construction if the object

this method is a coderef to the according function in InfluxDB::LineProtocol and generated within the constructor

as_string()

returns: the dataset in the InfluxDB line protocol format

AUTHOR

Thomas Berger <thomas.berger@1und1.de>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by 1&1 Telecommunication SE.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004