kais271 / pvc-exporter

Provides metrics to monitoring mounted pvc usage.
Apache License 2.0
43 stars 18 forks source link

获取不到pvc_usage指标 #22

Closed hbzhu closed 2 years ago

hbzhu commented 2 years ago

您好,使用的是阿里云flexvolume,运行的pvc-exporter-0.1.2,block-pvc-scanner获取不到pvc_usage指标,只有pvc_mapping

/dev/vdc 689G 584G 73G 89% /var/lib/kubelet/plugins/kubernetes.io/flexvolume/alicloud/disk/mounts/d-uf634xb8**

kais271 commented 2 years ago

block-pvc-scanner的log里有什么提示?

hbzhu commented 2 years ago

2021-12-01 09:15:08,282 - block_pvc_scanner - INFO - Will sleep 15s... │ │ 2021-12-01 09:15:23,299 - block_pvc_scanner - INFO - Will sleep 15s... │ │ 2021-12-01 09:15:38,323 - block_pvc_scanner - INFO - Will sleep 15s... │ │ 2021-12-01 09:15:53,350 - block_pvc_scanner - INFO - Will sleep 15s... │ │ 2021-12-01 09:16:08,372 - block_pvc_scanner - INFO - Will sleep 15s... │ │ 2021-12-01 09:16:23,392 - block_pvc_scanner - INFO - Will sleep 15s... │ │ 2021-12-01 09:16:38,411 - block_pvc_scanner - INFO - Will sleep 15s...

kais271 commented 2 years ago

进到block-pvc-scanner容器里执行df -h|grep flexvolume ,然后能把完整的路径放出来吗?我看看是不是匹配不到

hbzhu commented 2 years ago

/usr/src/app # df -h |grep flex /dev/vdb 19.6G 2.4G 16.1G 13% /host/var/lib/kubelet/plugins/kubernetes.io/flexvolume/alicloud/disk/mounts/d-uf63jr560**

kais271 commented 2 years ago

那它对应的PVC方便describe 一下,贴下结果吗

hbzhu commented 2 years ago

Name: search-es-data-search-es-0 Namespace: common StorageClass: alicloud-disk-essd Status: Bound Volume: d-uf63jr560** Labels: name.app.*.cn=search-es Annotations: control-plane.alpha.kubernetes.io/leader={"holderIdentity":"216c664a-d972-11e9-8346-0a***","leaseDurationSeconds":15,"acquireTime":"2021-04-07T05:35:33Z","renewTime":"2021-04-07T05:35:35Z","lea... pv.kubernetes.io/bind-completed=yes pv.kubernetes.io/bound-by-controller=yes volume.beta.kubernetes.io/storage-provisioner=alicloud/disk Finalizers: [kubernetes.io/pvc-protection] Capacity: 20Gi Access Modes: RWO Events:

kais271 commented 2 years ago

把block-pvc-scanner的镜像换成这个试试 dockerid31415926/block-pvc-scanner:tmp

hbzhu commented 2 years ago

感谢大佬,已经能获取到pvc_usage 指标数据了

kais271 commented 2 years ago

客气啦

hbzhu commented 2 years ago

(sum without (container,pod,service,namespace,job,instance,endpoint) (pvc_usage)) + on(volumename) group_left(persistentvolumeclaim,mountedby,pod_namespace)pvc_mapping*0 获取不到数据,貌似是volumename="d-uf65cq8kmgh***bha "} 多了空格

kais271 commented 2 years ago

哪个metric的返回多空格?

hbzhu commented 2 years ago

pvc_usage{volumename="d-uf65cq8km*ubha "}
日志显示也是 2021-12-03 07:32:47,427 - block_pvc_scanner - INFO - VOLUME: d-uf6fjo4***
y0g2r , USAGE: 0.96

hbzhu commented 2 years ago

是VOLUME: ('d-uf6j297lwv***bap\n 默认带了换行符

hbzhu commented 2 years ago

修改pv=volume.rstrip() ,已经可以了,谢谢大佬