3

The following command returns the metrics as expected:

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"}
 ]
}

If I try the same query using Cubism.js, I get a "unable to find metrics":

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);
});

Why Cubism.js can't find the metrics if it internally does the same request?

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
user1916077
  • 431
  • 1
  • 7
  • 18

1 Answers1

4

It was not a Cubism.js bug after all. Actually, it was a Cross-site HTTP request.

I enabled the Web Developer Extention in the Chrome and noticed the message:

origin is not allowed by Access-Control-Allow-Origin

And fixed adding the code below in the 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);
});
user1916077
  • 431
  • 1
  • 7
  • 18