How to rewrite InfluxQL to Flux

51 Views Asked by At

I'm using InfluxDB2 with Grafana, and I have a measurement called "data" with some tags and a field called buildnumber,project name and causer.

I need to fetch build number where project name should be linux and causer should conatins word called ui.

The following InfluxQL query does exactly what I need:

SELECT buildnumber FROM  "data"  WHERE "proj_name" =~ /linux/ AND "causer"=~ /ui/ ORDER BY time DESC LIMIT 1

how can I do the same in Flux?

I currently have the following query which does everything except filter by field:

from(bucket: "dbname")
  range(start: 0)
  filter(fn: (r) => r["_measurement"] == "data" )
  filter(fn: (r) => r["proj_name"] =~ /linux/ )
  sort(columns: ["_time"], desc: true)
  limit(n: 1)

but for above query if I add filter(fn: (r) => r["causer"] =~ /ui/) returns no results

0

There are 0 best solutions below