Giter Site home page Giter Site logo

influxdb-http's Introduction

NAME

InfluxDB::HTTP - The Perl way to interact with InfluxDB!

VERSION

Version 0.01

SYNOPSIS

InfluxDB::HTTP allows you top interact with the InfluxDB HTTP API. The module essentially provides one method per InfluxDB HTTP API endpoint, that is ping, write and query.

use InfluxDB::HTTP;

my $influx = InfluxDB::HTTP->new();

my $ping_result = $influx->ping();
print "$ping_result\n";

my $query = $influx->query(
    [ 'SELECT Lookups FROM _internal.monitor.runtime WHERE time > '.(time - 60)*1000000000, 'SHOW DATABASES'],
    epoch => 's',
);

print "$query\n";

SUBROUTINES/METHODS

RETURN VALUES AND ERROR HANDLING

Object::Result is relied upon for returning data from subroutines. The respective result object can always be used as string and evaluated on a boolean basis. A result object evaluating to false indicates an error and a corresponding error message is provided in the attribute error:

my $ping = $influx->ping();
print $ping->error unless ($ping);

new host => 'localhost', port => 8086

Passing host and/or port is optional, defaulting to the InfluxDB defaults.

Returns an instance of InfluxDB::HTTP.

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.

my $ping = $influx->ping();
print $ping->version if ($ping);

query query, database => "DATABASE", chunk_size => CHUNK_SIZE, epoch => "ns"

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.

write measurement, database => "DATABASE"

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.

get_lwp_useragent

Returns the internally used LWP::UserAgent instance for possible modifications (e.g. to configure an HTTP proxy).

AUTHOR

Raphael Seebacher, <[email protected]>

BUGS

Please report any bugs or feature requests to https://github.com/raphaelthomas/InfluxDB-HTTP/issues.

LICENSE AND COPYRIGHT

MIT License

Copyright (c) 2016 Raphael Seebacher

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.