【问题标题】:InfluxDB [Error: No host available]InfluxDB [错误:没有可用的主机]
【发布时间】:2014-10-11 17:39:42
【问题描述】:

我只是在尝试 InfluxDB。我正在使用他们文档中的修改示例来生成一些随机测试数据,但是当我使用节点运行它时,它会显示 [错误:没有可用的主机]。我尝试通过 curl 和 Web 控制台连接到 InfluxDB,它们都可以工作,所以我不确定它在哪里失败。

我刚刚安装了 influxdb 和 influx npm,所以有最新版本。

var influxdb = require('influx');
client = new influxdb.InfluxDB('localhost',8086, 'root', 'root', 'tempdb');

// start time of 24 hours ago
var backMilliseconds = 86000 * 1000;
var startTime = new Date() - backMilliseconds;
var timeInterval = 60 * 1000;
var eventTypes = ["click", "view", "post", "comment"];

var cpuSeries = {
  name:    "cpu_idle",
  columns: ["time", "value", "hostName"],
  points:  []
};

var eventSeries = {
  name:    "customer_events",
  columns: ["time", "customerId", "type"],
  points:  []
};

for (i = 0; i < backMilliseconds; i += timeInterval) {
  // generate fake cpu idle host values
  var hostName = "server" + Math.floor(Math.random() * 100);
  var value = Math.random() * 100;
  var pointValues = [startTime + i, value, hostName];
  cpuSeries.points.push(pointValues);

  // generate some fake customer events
  for (j = 0; j < Math.random() * 10; j += 1) {
    var customerId = Math.floor(Math.random() * 1000);
    var eventTypeIndex = Math.floor(Math.random() * 1000 % 4);
    var eventValues = [startTime + i, customerId, eventTypes[eventTypeIndex]];
    eventSeries.points.push(eventValues);
  }
}

client.writeSeries([cpuSeries, eventSeries],{},function(err){
    if(err) {
        console.log("Cannot write data",err);
    }
});

【问题讨论】:

    标签: node.js influxdb


    【解决方案1】:

    我认为构造函数已更改为采用选项映射而不是使用位置参数。见this example on the github repo

    【讨论】:

    • 最好的方案是将示例代码放在这里而不仅仅是一个 url。网址现在是 404 大声笑
    猜你喜欢
    • 2018-06-26
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    相关资源
    最近更新 更多