I have influx DB (time based) where I am trying to retrieve the data for 1 hour. I need to check how many Users logged in system for how many times in each hour by taking value as column.
Data has 3 columns- Time, user, and value
user is logging in at different time. so I am trying to aggregate the value of each user and want to take out top 3 user which has maximum value…
Time | User | value |
---|---|---|
12:00 PM | user1 | 3 |
12:10 | user 2 | 2 |
12:15 | user 1 | 6 |
12:20 | user 3 | 5 |
12:25 | user 1 | 4 |
12:35 | user 4 | 2 |
12:40 | user 5 | 5 |
12:45 | user 6 | 1 |
12:50 | user 2 | 3 |
12:55 | user 1 | 5 |
1:00 PM | user 6 | 3 |
from(bucket: “testdata”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “xyz”
|> filter(fn: (r) => r[“loc”] == “ABC” or r[“loc”] == “DEF”)
|> filter(fn: (r) => r[“count_type”] == “items”)
|> group(columns: [“user”, “loc”])
|> sort(columns: [“_value”], desc: true)
|> aggregateWindow(every: 24h, fn:sum, createEmpty: false )
|> aggregateWindow(every: 1mo, fn: max)
I am getting resut but I am not getting top 3 result… Am i missing anything ? please let me know.