0

I have a measurement of the player counts on multiple game servers, every time a player leaves or joins the server, the server writes a point to influx containing the player count and the server's unique id.

What I am trying to do is sum the last point for each unique server id.

example points:

04:30 server-a: 45
04:31 server-b: 56
04:32 server-a: 78

the current total would be: 134

I have been able to get the last points for each server with the following query.

from(bucket: "metrics")
  |> range(start: -1m)
  |> filter(fn: (r) => r._measurement == "player_count")
  |> last()

Any help would be greatly appreciated :)

Marshall Walker
  • 343
  • 1
  • 10

1 Answers1

2

You need to group your data and then sum it. Add this to your influx query:

|> group()
|> sum()
Beowolve
  • 548
  • 2
  • 13