From 93acaad4233dae0f7ecf575b483f8bfdca46477e Mon Sep 17 00:00:00 2001 From: Matthew VanTassel Date: Sun, 12 Feb 2017 11:10:17 -0400 Subject: [PATCH] Update influx api to use writeMeasurement for v5 --- nzb2influx.js | 16 ++++++++++++---- package.json | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nzb2influx.js b/nzb2influx.js index 9671e0d..548149b 100644 --- a/nzb2influx.js +++ b/nzb2influx.js @@ -20,8 +20,16 @@ const nzbgetConfig = { password: process.env.NZBGET_PASSWORD || '' }; -function writeToInflux(seriesName, values, tags, callback) { - return influxClient.writePoint(seriesName, values, tags, callback); +function writeToInflux(seriesName, values, tags) { + var payload = { + fields: values + }; + + if (tags) { + payload.tags = tags; + } + + return influxClient.writeMeasurement(seriesName, [payload]); } const ng = new nzbget({ @@ -43,14 +51,14 @@ function onGetNZBData(data) { category: nzb.Category }; - writeToInflux('nzb', value, tags, function() { + writeToInflux('nzb', value, tags).then(function() { console.dir(`wrote ${nzb.NZBName} nzb data to influx: ${new Date()}`); }); }); writeToInflux('nzbs', { count: nzbs.length - }, null, function() { + }, null).then(function() { console.dir(`wrote ${nzbs.length} nzbs data to influx: ${new Date()}`); restart(); }); diff --git a/package.json b/package.json index 10ed0a2..54dab5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nzb2influx", - "version": "0.1.1", + "version": "0.1.2", "private": true, "scripts": { "start": "node nzb2influx.js"