38 lines
14 KiB
Markdown
38 lines
14 KiB
Markdown
# PersistentVolume Metrics
|
|
|
|
| Metric name | Metric type | Description | Unit (where applicable) | Labels/tags | Status |
|
|
|------------------------------------------|-------------|---------------------------------------------------------------------------------------------------------------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
|
|
| kube_persistentvolume_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](../../developer/cli-arguments.md) | | `persistentvolume`=<persistentvolume-name> <br> `annotation_PERSISTENTVOLUME_ANNOTATION`=<PERSISTENTVOLUME_ANNOTATION> | EXPERIMENTAL |
|
|
| kube_persistentvolume_capacity_bytes | Gauge | | | `persistentvolume`=<pv-name> | STABLE |
|
|
| kube_persistentvolume_status_phase | Gauge | | | `persistentvolume`=<pv-name> <br>`phase`=<Bound\|Failed\|Pending\|Available\|Released> | STABLE |
|
|
| kube_persistentvolume_claim_ref | Gauge | | | `persistentvolume`=<pv-name> <br>`claim_namespace`=`<namespace>`; <br>`name`=`<name>`; | STABLE |
|
|
| kube_persistentvolume_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | | `persistentvolume`=<persistentvolume-name> <br> `label_PERSISTENTVOLUME_LABEL`=<PERSISTENTVOLUME_LABEL> | STABLE |
|
|
| kube_persistentvolume_info | Gauge | Information about Persistent Volumes | | `persistentvolume`=<pv-name> <br> `storageclass`=<storageclass-name> <br> `gce_persistent_disk_name`=<pd-name> <br> `host_path`=<path-of-a-host-volume> <br> `host_path_type`=<host-mount-type> <br> `ebs_volume_id`=<ebs-volume-id> <br> `azure_disk_name`=<azure-disk-name> <br> `fc_wwids`=<fc-wwids-comma-separated> <br> `fc_lun`=<fc-lun> <br> `fc_target_wwns`=<fc-target-wwns-comma-separated> <br> `iscsi_target_portal`=<iscsi-target-portal> <br> `iscsi_iqn`=<iscsi-iqn> <br> `iscsi_lun`=<iscsi-lun> <br> `iscsi_initiator_name`=<iscsi-initiator-name> <br> `local_path`=<path-of-a-local-volume> <br> `local_fs`=<local-volume-fs-type> <br> `nfs_server`=<nfs-server> <br> `nfs_path`=<nfs-path> <br> `csi_driver`=<csi-driver> <br> `csi_volume_handle`=<csi-volume-handle> <br> `reclaim_policy`=<reclaim-policy> | STABLE |
|
|
| kube_persistentvolume_created | Gauge | Unix creation timestamp | seconds | `persistentvolume`=<persistentvolume-name> <br> | EXPERIMENTAL |
|
|
| kube_persistentvolume_deletion_timestamp | Gauge | Unix deletion timestamp | seconds | `persistentvolume`=<persistentvolume-name> <br> | EXPERIMENTAL |
|
|
| kube_persistentvolume_csi_attributes | Gauge | CSI attributes of the Persistent Volume, disabled by default, manage with [--metric-opt-in-list](../../developer/cli-arguments.md)) | | `persistentvolume`=<persistentvolume-name> <br> `csi_mounter`=<csi-mounter> <br> `csi_map_options`=<csi-map-options> | EXPERIMENTAL |
|
|
| kube_persistentvolume_volume_mode | Gauge | Volume Mode information for the PersistentVolume. | | `persistentvolume`=<persistentvolume-name> <br>`volumemode`=<volumemode> | EXPERIMENTAL |
|
|
|
|
## Useful metrics queries
|
|
|
|
### How to retrieve non-standard PV state
|
|
|
|
It is not straightforward to get the PV states for certain cases like "Terminating" since it is not stored behind a field in the `PersistentVolume.Status`.
|
|
|
|
So to mimic the [logic](https://github.com/kubernetes/kubernetes/blob/v1.27.2/pkg/printers/internalversion/printers.go#L1838) used by the `kubectl` command line, you will need to compose multiple metrics.
|
|
|
|
Here is an example of a Prometheus rule that can be used to alert on a PV that has been in the `Terminating` state for more than `5m`.
|
|
|
|
```yaml
|
|
groups:
|
|
- name: PV state
|
|
rules:
|
|
- alert: PVBlockedInTerminatingState
|
|
expr: kube_persistentvolume_deletion_timestamp * on(persistentvolume) group_left() (kube_persistentvolume_status_phase{phase="Bound"} == 1) > 0
|
|
for: 5m
|
|
labels:
|
|
severity: warning
|
|
annotations:
|
|
summary: PV {{$labels.persistentvolume}} blocked in Terminating state.
|
|
```
|