Count records in real time

Hi all. Wanted to count number of records in real time. But its taking time to calculate for me, i am using flux query to count. I am using telegraf and influxdb, is there any way i can get the count in real time, with not much delay. Is telegraf or influxdb stores counts of records pushed internally, is running task is only way to compute and get results in run time?

Thanks

What’s the size of rows within the count typically?

What hardware specs are you running your dB on?

How much delay is acceptable for your use case?

Can you paste your flux query you have currently within a <> code block - there might be some optimization possible?

Also possible that your schema may need adjusting . This page does a good job explaining high cardinality :

I am using ec2 instance with influxdb installed as docker container. The instance type is t2.xlarge, and delay is max 30 seconds.

from(bucket: "bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "measurement")
  |> group(columns:["tag"])
  |> aggregateWindow(every: 1h, fn: count, createEmpty: false)

  |> yield(name: "mean")

This is my query. Thanks for above link, will check on that.

Create another column. In it you count up the rows. With a new data record you increase the column by 1. When reading out you must only read out the column in the last data record.