问题
I want to build a static html page which retrieves data from influxDB. Is there any jquery/ajax solution or even a js library to do this? I've tried to use influent, an InfluxDB driver for Javascript apps which says it can work in browser but I had no success when I tried to use influent.js
回答1:
I captured with the developer tools the http requests that Grafana sends in order to create graphs and tried to do the same with jQuery get():
// something like this
$.get("http://localhost:8086/query?db=mydb&epoch=ms&q=SELECT+mean(value)+FROM+%22cpu_load_short%22+WHERE+time+%3E+1443610329s+and+time+%3C+1443629449s+GROUP+BY+time(30s)").done(
function (data) { console.log(data);
});
InfluxDB returns JSON which I later handle and create a graph. See influxDB - Querying data
回答2:
Influent is the best maintained javascript library for InfluxDB. If it's not working, you would probably be better served to open an issue on the repo than to find another library. I am unaware of any other libraries that are compatible with InfluxDB 0.9
来源:https://stackoverflow.com/questions/32971011/retrieve-data-from-influxdb-with-javascript-client-side-using-a-browser