我刚开始尝试使用 influxDB 和 influxDB 节点模块。
我有以下代码,每秒插入一些随机数据。我没有收到任何错误,但没有数据添加到我的时间序列中。
代码是:
var influxdb = require('influxdb');
var sleep = require('sleep');
var connection = influxdb('172.21.5.67', 8086);
connection.auth({ name: 'root', password: 'root' });
var db;
var ISCSIDataSeries;
function random (low, high) {
return Math.floor(Math.random() * (high - low) + low);
}
function doInsert(i) {
if (db == undefined) {
db = connection.database('test');
console.log('established the db connection');
}
if (ISCSIDataSeries == undefined) {
ISCSIDataSeries = db.series('SCSIData');
console.log('the series SCSIData is established');
}
var reads = random(1000, 10000);
var writes = random(2000, 20000);
var IOS = random(100000, 1000000);
ISCSIDataSeries.writePoints({
'columns': ['Volume', 'Reads', 'Writes'],
'points': [reads, writes, IOS]
});
db.save();
}
var i = 0;
while (i < 10) {
sleep.sleep(1);
doInsert(i);
i ++;
}
console.log('so long folks');
在运行结束时,我没有看到任何数据输入。有这个包的经验吗?