Hi there
I am looking for an example of how to call Flux queries from NodeJS with datetime window with a start and end date.
I am currently doing something like this:
const from = new Date("09/28/2023 16:00:00").valueOf();
const to = new Date("09/28/2023 16:01:00").valueOf();
const windowPeriod = "1s";
let fluxQuery = `
from(bucket: "bucket name")
|> range(start: ${from}, stop: ${to})
|> filter(fn: (r) => filter code here)
|> filter(fn: (r) =>more filters here)
|> filter(fn: (r) => r["_field"] == 'fields go here')
|> group(columns: ["col 1", "col 2", "col"])
|> yield(name: "mean")`;
The query is working, but is seems like it is ignoring my range function is not working. It seems like it is returning data outside of the range specified. And I am not sure if the way that I am sending in the parameters into the range is correct.
I couldn’t find any similar example code for running this kind of query from NodeJS.
I would appreciate some feedback on my query approach and clarity on how to send parameters into a flux query from NodeJS.