I am using python language for getting data. I am following documentation as mentioned in UI and documentation as well. I am trying to get json data without manual loop perform by python.
Here is an example -
If measurement - test
fields are f1,f2 and values are 10, 20 and 50, 60 respectively.
I want data like -
[{“time”:, “f1”:10, “f2”:20},{“time”:, “f1”:50, “f2”:60}]
I am using -
|> map(fn: (r) => ({ r with
jsonStr: string(v: json.encode(v: {“OriginalTime”:r.OriginalTime,“time”:r._time}))}))
as mentioned in documentation. but its not working.
Is there any way to get data like my desired json output by FluxQL or Python(Without loop)?
It will be helpful for me.
Just FYI - I got an email from Harrison(InfluxDB Data) for feed back call. I replied but no one get back.
Welcome to the forum.
Your post is bit hard to read from the formatting, can you edit it and put the code inside a code block </>
Yes. Pretty much any language can query from influxdb using a standard web rest api call.
From python you’d declare something to hold the result, either an array, reference or list object.
You construct the flux query similar to what you’ve already got.
You then send the http request to the influxdb , which you’ll need to create a token for your script to use.
The result you get back (should be http return code 200) will contain a json response.
Most languages now have a built in json parser that will convert it into a datastructure that’s native for that language.
I have a little request that, if in future flux can export to json directly from influxdb without using http post, please let me know.
Because if i looped it from object to json or csv to json in python, it will be overhead for the application. Im building a restapi in flux which only return json will be use in our IOT platform where milisec. latency will cause trouble.