0.1.3 • Published 8 years ago

telegrafjs v0.1.3

Weekly downloads
722
License
Apache-2.0
Repository
github
Last release
8 years ago

TelegrafJS

A Promise-based TCP/UDP client for sending application metrics to Telegraf/InfluxDB.

Install

npm install --save telegrafjs

Example

const telegraf = require('telegrafjs');
const Measurement = telegraf.Measurement;
const Int = telegraf.Int;
const Float = telegraf.Float;
const TelegrafUDPClient = telegraf.TelegrafUDPClient;
const TelegrafTCPClient = telegraf.TelegrafTCPClient;

let m1 = new Measurement(
    "metric-name",
    { tag1: "tagval1" },
    {
        integer_field: new Int(integer_field),
        float_field: new Float(10.1),
        boolean_field: true,
        string_field: "yoohoo"
    }
);

let client = new TelegrafUDPClient(); // or TelegrafTCPClient()
client.connect()
.then(() => {
    return client.sendMeasurement(m1);
})
.then(() => {
    client.close();
});

Links

License

Apache 2.0