veertuinc / anka-prometheus-exporter

A server that connects Anka Cloud to Prometheus
MIT License
7 stars 2 forks source link

[Feature Request] gitlab runner per user and per user group metrics #23

Open dennispost opened 2 years ago

dennispost commented 2 years ago

Hey,

we need to get the run duration of each instance per user/usergroup. So that we can report the sum of total duration in minutes per user / month.

Can you report such a metric? E.g. anka_instance_state_per_user or anka_instance_state_per_usergroup

Thanks

NorseGaud commented 2 years ago

Hi @dennispost , what do you mean by user/usergroup? Can you give me an example?

dennispost commented 2 years ago

Hey @NorseGaud , my idea was to calculate the sum of every minute where a user has an anka_instance in running_state. So that we can report the sum of all running minutes per month.

I know that this does work in Enterprise Plus license tier only.

NorseGaud commented 2 years ago

Do you mean the users of a certificate using certificate authentication? What sort of authentication method are you using?

dennispost commented 2 years ago

As user I mean the user who has started the instance (e.g. with his acces token via a gitlab-runner). We've not configured authentication in our setup yet.

NorseGaud commented 2 years ago

Got it -- thanks for the clarification.

In order to achieve this, the gitlab runner executor we created needs to post metadata with all of the available/relevant information that you want available in the exporter. This is because the exporter is a consumer of the API JSON from the Controller. If you start an instance with specific metadata (see API docs), it will be available on the instance object.

While we could modify both the runner executor to do this and then set up the exporter to consume it, this creates a situation where a feature of the exporter will only work if you're using the gitlab runner. I'm not sure if our dev team wants to accomplish it this way. I'll have a conversation with them about it and see what they recommend.

dennispost commented 2 years ago

Thanks for reaching out to your dev team.

The runner authenticates with credentials of a specific user or group. So these information are not stored currently? If these would be stored, they could be available to the exporter. This is also not specific for gitlab, but maybe a general feature which should be added.

NorseGaud commented 2 years ago

The runner and Controller are only able to communicate over the Controller's API (when it goes to request or terminate a VM). It only receives and sees what we pass into the API by the runner anka executor code.