10.3. La résolution du tir d’alerte KubePersistentVolumeFillingUp pour Prometheus
En tant qu’administrateur de cluster, vous pouvez résoudre l’alerte KubePersistentVolumeFillingUp déclenchée pour Prometheus.
L’alerte critique s’allume lorsqu’un volume persistant (PV) revendiqué par un pod prometheus-k8s-* dans le projet de surveillance à temps ouvert a moins de 3% d’espace total restant. Cela peut causer Prométhée à fonctionner anormalement.
Il y a deux alertes KubePersistentVolumeFillingUp:
- Alerte critique: L’alerte avec l’étiquette sévérité="critique" est déclenchée lorsque le PV monté a moins de 3% d’espace total restant.
- Alerte: L’alerte avec l’étiquette sévérité="avertissement" est déclenchée lorsque le PV monté a moins de 15% d’espace total restant et devrait se remplir dans les quatre jours.
Afin de résoudre ce problème, vous pouvez supprimer les blocs Prometheus time-series (TSDB) pour créer plus d’espace pour le PV.
Conditions préalables
- En tant qu’utilisateur, vous avez accès au cluster avec le rôle d’administrateur dédié.
- L’OpenShift CLI (oc) a été installé.
Procédure
Énumérez la taille de tous les blocs TSDB, triés du plus ancien au plus récent, en exécutant la commande suivante:
oc debug <prometheus_k8s_pod_name> -n openshift-monitoring \ -c prometheus --image=$(oc get po -n openshift-monitoring <prometheus_k8s_pod_name> \ -o jsonpath='{.spec.containers[?(@.name=="prometheus")].image}') \ -- sh -c 'cd /prometheus/;du -hs $(ls -dt */ | grep -Eo "[0-9|A-Z]{26}")'
$ oc debug <prometheus_k8s_pod_name> -n openshift-monitoring \
1 -c prometheus --image=$(oc get po -n openshift-monitoring <prometheus_k8s_pod_name> \
2 -o jsonpath='{.spec.containers[?(@.name=="prometheus")].image}') \ -- sh -c 'cd /prometheus/;du -hs $(ls -dt */ | grep -Eo "[0-9|A-Z]{26}")'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Exemple de sortie
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Identifiez quels blocs et combien de blocs pourraient être supprimés, puis supprimez les blocs. La commande d’exemple suivante supprime les trois plus anciens blocs Prometheus TSDB de la boîte prométhée-k8s-0:
oc debug prometheus-k8s-0 -n openshift-monitoring \ -c prometheus --image=$(oc get po -n openshift-monitoring prometheus-k8s-0 \ -o jsonpath='{.spec.containers[?(@.name=="prometheus")].image}') \ -- sh -c 'ls -latr /prometheus/ | egrep -o "[0-9|A-Z]{26}" | head -3 | \ while read BLOCK; do rm -r /prometheus/$BLOCK; done'
$ oc debug prometheus-k8s-0 -n openshift-monitoring \ -c prometheus --image=$(oc get po -n openshift-monitoring prometheus-k8s-0 \ -o jsonpath='{.spec.containers[?(@.name=="prometheus")].image}') \ -- sh -c 'ls -latr /prometheus/ | egrep -o "[0-9|A-Z]{26}" | head -3 | \ while read BLOCK; do rm -r /prometheus/$BLOCK; done'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Vérifiez l’utilisation du PV monté et assurez-vous qu’il y a suffisamment d’espace disponible en exécutant la commande suivante:
oc debug <prometheus_k8s_pod_name> -n openshift-monitoring \ --image=$(oc get po -n openshift-monitoring <prometheus_k8s_pod_name> \ -o jsonpath='{.spec.containers[?(@.name=="prometheus")].image}') -- df -h /prometheus/
$ oc debug <prometheus_k8s_pod_name> -n openshift-monitoring \
1 --image=$(oc get po -n openshift-monitoring <prometheus_k8s_pod_name> \
2 -o jsonpath='{.spec.containers[?(@.name=="prometheus")].image}') -- df -h /prometheus/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow L’exemple de sortie suivant montre le PV monté revendiqué par le pod prometheus-k8s-0 qui a 63% de l’espace restant:
Exemple de sortie
Starting pod/prometheus-k8s-0-debug-j82w4 ... Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p4 40G 15G 40G 37% /prometheus Removing debug pod ...
Starting pod/prometheus-k8s-0-debug-j82w4 ... Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p4 40G 15G 40G 37% /prometheus Removing debug pod ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow