使用Cubism.js找不到Graphite指标

时间:2012-12-19 14:35:04

标签: graphite cubism.js

以下命令按预期返回指标:

curl" http://graphite.metrics:8080/metrics/find?format=completer&query=server * .cache"

{"metrics": [
  {"is_leaf": "1", "path": "server1200.cache", "name": "cache"},
  {"is_leaf": "1", "path": "server1201.cache", "name": "cache"},
  {"is_leaf": "1", "path": "server1202.cache", "name": "cache"},
  {"is_leaf": "1", "path": "server1203.cache", "name": "cache"}, 
  {"is_leaf": "1", "path": "server1205.cache", "name": "cache"}
 ]
}

如果我使用Cubism.js尝试相同的查询,我会得到一个"无法找到指标":

var context = cubism.context()
                    .serverDelay(60 * 1000) 
                    .step(60 * 1000)
                    .size(1440); 

var graphite = context.graphite("http://graphite.metrics:8080");  
graphite.find("metricXX*", function(error, results){
  alert(error);
});

如果Cubism.js在内部执行相同的请求,为什么无法找到指标?

1 个答案:

答案 0 :(得分:4)

毕竟这不是Cubism.js的错误。实际上,这是一个跨站点HTTP请求。

我在Chrome中启用了Web Developer Extention并注意到了以下消息:

  Access-Control-Allow-Origin

不允许

原点

并修复了在Node.js中添加以下代码:

var server = http.createServer(function (req, res) {

  res.setHeader("Access-Control-Allow-Origin", "*");
  res.setHeader("Access-Control-Allow-Headers", "X-Requested-With");

  proxy.proxyRequest(req, res);
});