Hi,
I’m using InfluxDB to collect data with telegraf, I would like to be able to monitor the number of client that is sending data to my bucket over time. I didn’t find any predifined counter that seems to collect this information so I’m using the host tag to try to count the unique occurence at specific timerange. I cannot get the expected result.
The beginning of the request I’m trying to use is :
from(bucket: “telegraf_bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == “cpu” or r["_measurement"] == “win_cpu”)
|> filter(fn: (r) => r["_field"] == “Percent_Idle_Time” or r["_field"] == “usage_idle”)
|> map(fn: (r) => ({
_time: r._time,
_value: r.host
}))
//|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
The result is :
table _value _time
0 srv01 2022-04-04T13:49:10.000Z
0 srv01 2022-04-04T13:49:10.000Z
0 srv01 2022-04-04T13:49:10.000Z
0 srv02 2022-04-04T13:49:10.000Z
0 srv02 2022-04-04T13:49:10.000Z
0 srv01 2022-04-04T13:49:20.000Z
0 srv01 2022-04-04T13:49:20.000Z
0 srv01 2022-04-04T13:49:20.000Z
0 srv02 2022-04-04T13:49:21.000Z
0 srv02 2022-04-04T13:49:21.000Z
0 srv01 2022-04-04T13:49:30.000Z
What I expect to get to be able to display it on a graph is :
table _value _time
0 2 2022-04-04T13:49:10.000Z
0 1 2022-04-04T13:49:20.000Z
0 1 2022-04-04T13:49:21.000Z
0 1 2022-04-04T13:49:30.000Z
_value would be the result of grouping _time and counting distinct occurence of _value.
I tried to achieve that with unique, distinct, count etc. with no result.
Do you have any advice on how it could be possible to get the information?
Thanks