Search code examples
influxdbinfluxdb-2flux-influxdb

Get the number of points in a bucket for a time interval with Flux query


Given a bucket how do I get the number of points in this bucket with the timestamp in the given time interval using a Flux query?

I'm trying to estimate how much data is added to an influxdb2 bucket per unit of time.


Solution

  • This is what I ended up doing:

    from(bucket: "mybucket")
      |> range(start: -1m)
      |> group()  
      |> count()
    

    In my case there's a very big number of series (table streams returned by from) in the bucket so I had to add group() with no arguments to combine it into a single table before count(). It would return the count for each table separately otherwise.

    From the flux manual:

    An empty group key groups all data in a stream of tables into a single table