googleforgames / agones

Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
https://agones.dev
Apache License 2.0
6k stars 791 forks source link

Not able to get allocated and scheduled time for gameservers #3395

Open oll-aroundarmor opened 11 months ago

oll-aroundarmor commented 11 months ago

Issue: I was trying to get metrics for gameserver in prometheus by using agones_gameserver_state_duration_sum but it is providing me values for agones-controller/fleet allocated and scheduled state.

What I want: I want to get the agones-sdk metrics in order to get the details for how much time an individual gameserver was in an allocated and scheduled state.

Help-needed:

  1. Suggestion if there is any way through which I can get those metrics to reflect for individual gameservers.
  2. Is there a way I can get a service and service monitor for agones-sdk?

Any suggestions would be greatly appreciated.

markmandel commented 11 months ago

Thanks for the question!

Suggestion if there is any way through which I can get those metrics to reflect for individual gameservers.

You can't get at individual GameServer metrics as metrics are aggregate values.

If you want to watch individual GameServers, I recommend writing some small code to interact with the Kubernetes API: https://agones.dev/site/docs/guides/access-api/

Is there a way I can get a service and service monitor for agones-sdk?

Sorry, not quite sure what you mean by this - can you expand on it in more detail?

oll-aroundarmor commented 11 months ago

Sure, Mark!

As I earlier stated I wanted the individual gameserver's allocated and scheduled time durations but I checked and found that the service monitor is only configured for the agones-controller which in response gives the output of the whole fleet.

I wanted to add an additional service and servicemonitor which will be providing the outputs for agones-sdk.

For example: In the below presentation, you will find that the gameservers are getting scheduled, and based on it its SDK state changes and gets logged on the Kubernetes events. If I can get the service and service monitor for agones-sdk I will be able to get the metrics for individual gameservers from agones_gameserver_state_duration_sum.

`

LAST-SEEN TYPE REASON OBJECT MESSAGE
119s Normal Allocated gameserver/project-cricket-fleet-w7pf6-5lbl7 Allocated
26s Normal Shutdown gameserver/project-cricket-fleet-w7pf6-5lbl7 SDK state change
26s Normal Shutdown gameserver/project-cricket-fleet-w7pf6-5lbl7 Deletion started
26s Normal Killing pod/project-cricket-fleet-w7pf6-5lbl7 Stopping container agones-gameserver-sidecar
26s Normal Shutdown gameserver/project-cricket-fleet-w7pf6-5lbl7 Deleting Pod project-cricket-fleet-w7pf6-5lbl7
26s Normal Killing pod/project-cricket-fleet-w7pf6-5lbl7 Stopping container project-cricket

`

Let me know if you have any questions.

markmandel commented 11 months ago

If I can get the service and service monitor for agones-sdk I will be able to get the metrics for individual gameservers from agones_gameserver_state_duration_sum.

Sorry I don't follow how this approach works? Metrics are aggregated, they aren't per GameServer, and you don't really want to do this, because metric services can't handle combinatoric explosion with an essentially infinite number of labels.

I'll put it another way - getting per-GameServer information out of metrics is going to be a non starter.

Watch the Kubernetes API for GameServer changes to do this. Or use the Event stream, that would work as well.

github-actions[bot] commented 1 month ago

'This issue is marked as Stale due to inactivity for more than 30 days. To avoid being marked as 'stale' please add 'awaiting-maintainer' label or add a comment. Thank you for your contributions '

github-actions[bot] commented 6 days ago

This issue is marked as obsolete due to inactivity for last 60 days. To avoid issue getting closed in next 30 days, please add a comment or add 'awaiting-maintainer' label. Thank you for your contributions