Skip to content

Conversation

jiphex
Copy link

@jiphex jiphex commented Jul 28, 2025

Change the usage quota reported to show the default for the filesystem, if set to 0 in the user's own, to allow the quota metric to be reported for users without a specific quota set.

I don't know if this should be implemented like I've done here in the pull request, or added as a third dimension so that both the default quota for the filesystem and the specific quota for a user can be seen - I guess the way as implemented may be somewhat disruptive to users of the current metric, but it is currently displayed as 0 unless specifically set, and I'm not sure how useful that is.

Also, I don't know if it's possible to manually set a quota for a user to 0, if it is then in this implementation it may be erroneous to show it as the default quota.

@jiphex
Copy link
Author

jiphex commented Aug 20, 2025

@sdodsley is there a process for getting PRs merged that I've missed? Happy to do what's required, we'd rather not run a fork of this with our own changes to see quotas in the Prometheus output so it'd be great to hear if this is anywhere near being able to be merged!

@sdodsley sdodsley added the bug Something isn't working label Aug 20, 2025
@sdodsley
Copy link
Collaborator

Let me get someone to look at it

@chrroberts-pure
Copy link
Collaborator

chrroberts-pure commented Aug 20, 2025

Hi! Thanks for the PR. I agree that 0 is not the best value for this.

My gut feeling on this is that a dimension with an unset value should null, not 0 or set to another value. I need to review the Purity//FB API to see how they supply those values when they’re unset.

Eg quota=“”

To track quotas, I could also suggest that we start publishing a new metric for quotas. We could only publish metric values for instances where a quota is set

Would that be an acceptable solution @jiphex ?

I will review further and provide my input and suggestions as I do a little more research

Copy link
Collaborator

@chrroberts-pure chrroberts-pure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Purity//FB API will provide null when a quota isn't set for a user, but will not provide null for the default quota value if it is not set. This isn't great, and could be dealt with if the FB API team implement null later.

            "quota": null,
            "file_system_default_quota": 0,

if len(ugroups.Items) > 0 {
for _, usage := range ugroups.Items {
gid = strconv.Itoa(usage.Group.Id)
// Set quotaValue to the quota
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described here, I could not get your requested logic to work since the var gets lost in the if statement.

Something this could work

			// If User Usage Quota is null use the File System Default Quota
			if usage.Quota == nil {
				ch <- prometheus.MustNewConstMetric(
					c.UsageUsersDesc,
					prometheus.GaugeValue,
					usage.FileSystemDefaultQuota,
					usage.FileSystem.Name, usage.User.Name, uid, "quota",
				)
			} else {
				ch <- prometheus.MustNewConstMetric(
					c.UsageUsersDesc,
					prometheus.GaugeValue,
					*usage.Quota,
					usage.FileSystem.Name, usage.User.Name, uid, "quota",
				)
			}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the User/Group User Quota data type needs to be set from float64 to *float64 to deal with null/nil values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants