Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add persistent volume capacity metric #674

Merged
merged 3 commits into from
Feb 22, 2019

Conversation

r0fls
Copy link
Contributor

@r0fls r0fls commented Feb 16, 2019

What this PR does / why we need it: Add kube_persistentvolume_capacity to track PV capacity.

Which issue(s) this PR fixes:
Fixes #555

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 16, 2019
{
Name: "kube_persistentvolume_capacity",
Type: metric.MetricTypeGauge,
Help: "persistentvolume capacity in Gigabytes.",
Copy link
Member

Choose a reason for hiding this comment

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

prometheus metrics best practice is to use base units, so this should be bytes (we're not loosing precision because we're using float64)

Type: metric.MetricTypeGauge,
Help: "persistentvolume capacity in Gigabytes.",
GenerateFunc: wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family {
storage := p.Spec.Capacity[v1.ResourceStorage]
Copy link
Member

Choose a reason for hiding this comment

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

could there ever be an additoinal capacity? if so we should make the v1.ResourceStorage a label instead, similar to what we do with resource_requests on pod/containers

Copy link
Contributor Author

@r0fls r0fls Feb 19, 2019

Choose a reason for hiding this comment

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

I do not believe there can ever be an additional capacity, because p.Spec.Capacity is a v1.ResourceList, which in turn is a map[ResourceName]resource.Quantity. So, there will only be one resource.Quantity for each ResourceName in the map (in this case the resource name is v1.ResourceStorage).

The name v1.ResourceList is a little misleading in that regard, but since it's a map to resource.Quantity (which is never a list) I think we're good.

{
Name: "kube_persistentvolume_capacity",
Type: metric.MetricTypeGauge,
Help: "persistentvolume capacity in Gigabytes.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Help: "persistentvolume capacity in Gigabytes.",
Help: "Persistentvolume capacity in gigabytes.",

Plus the suggestion by @brancz.

@r0fls
Copy link
Contributor Author

r0fls commented Feb 20, 2019

Looks like the build probably needs restarting:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

@@ -108,6 +108,21 @@ var (
}
}),
},
{
Name: "kube_persistentvolume_capacity",
Copy link
Member

Choose a reason for hiding this comment

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

if resource storage is the only capacity possible then this should be kube_persistentvolume_capacity_bytes

@brancz
Copy link
Member

brancz commented Feb 21, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 21, 2019
@brancz
Copy link
Member

brancz commented Feb 21, 2019

Sorry about that, looks like a recent merge created a conflict. Could you rebase this? Thanks!

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 22, 2019
@r0fls
Copy link
Contributor Author

r0fls commented Feb 22, 2019

@brancz no problem, rebased ✔️

@r0fls
Copy link
Contributor Author

r0fls commented Feb 22, 2019

By the way it was just that the Documentation directory was renamed docs

Copy link
Contributor

@tariq1890 tariq1890 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 22, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brancz, r0fls, tariq1890

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add metric for persistent volume size
5 participants