Retrieve data from InfluxDB with javascript (client-side, using a browser)

妖精的绣舞 提交于 2019-12-13 07:25:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!