Flux Query: How to add row number to result of query?

I’ve a query that returns the results of collected metrics of each devices in field.

I just want to give information to the end user about numeric placement on given time arrange.

There may be a better or “canonical” way to approach this, but I believe the following would accomplish what you need:

from(bucket: "db/autogen")
  |> range(start: -24h)
  // Create a new column for row Id with an initial value of 1
  |> map(fn: (r) => ({r with rowId: 1}))
  // Taking the cumulative sum gives sequential values 1,2,3,4 et...
  |> cumulativeSum(columns: ["rowId"])