I'm one of the maintainers of InfluxDB. We don't use node so I wasn't familiar with the library, but I tried your snippet and indeed it doesn't work. It turns out that the influxdb
library isn't up to date and was last updated four months ago, during which InfluxDB api went through significant changes. I recommend you switch to the influx package instead which seems to be more actively maintained. I modified your code snippet to work with the other package and it works succesfuly:
var influxdb = require('influx');
var sleep = require('sleep');
var root = new influxdb.InfluxDB('localhost', 8086, 'root', 'root');
root.createDatabase('SCSIData', function(err) {
if (err && err.message.indexOf("exist") == -1) {
console.log("Cannot create db", err);
process.exit(1);
};
var client = new influxdb.InfluxDB('localhost', 8086, 'root', 'root', 'SCSIData');
function random (low, high) { return Math.floor(Math.random() * (high - low) + low); }
function doInsert(i) {
var reads = random(1000, 10000);
var writes = random(2000, 20000);
var IOS = random(100000, 1000000);
client.writePoint("series.name", {
'Volume': IOS,
'Reads': reads,
'Writes': writes
}, function(err) {
if (err) {
console.log("Cannot write data", err);
process.exit(1);
}
});
}
var i = 0;
while (i < 10) {
doInsert(i);
i++;
}
client.query("select count(Reads) from series.name", function(err, result) {
if (err) {
console.log("Cannot write data", err);
}
console.log("result", result)
console.log("Number of points: ", result[0].points[0][1]);
})
});
console.log('so long folks');