[英]How to monitor disk usage of persistent volumes of all storageclasses using Prometheus?
I am using Kubernetes Persistent Volumes dashboard on Grafana to view the disk usage for my PVCs.我在 Grafana 上使用Kubernetes Persistent Volumes仪表板来查看我的 PVC 的磁盘使用情况。 This dashboard makes use of
kubelet_volume_stats_used_bytes
metric to fetch the data for the PVCs and I am able to visualize it as well.该仪表板使用
kubelet_volume_stats_used_bytes
指标来获取 PVC 的数据,我也可以将其可视化。
But, it does not display the PVCs which use EFS as storageclass.但是,它不显示使用 EFS 作为存储类的 PVC。 I found some stackoverflow answers and comments regarding the same, but none of them included a solution.
我发现了一些关于相同问题的 stackoverflow 答案和评论,但没有一个包含解决方案。
How to monitor kubernetes persistence volume claim ie disk usage 如何监控 kubernetes 持久性卷声明即磁盘使用情况
How to monitor disk usage of kubernetes persistent volumes? 如何监控 kubernetes 持久卷的磁盘使用情况?
So my question is how do get usage metrics for EFS PVCs?所以我的问题是如何获取 EFS PVC 的使用指标? Or to make it more generic - how to scrape PVC metrics for all storageclasses?
或者让它更通用——如何抓取所有存储类的 PVC 指标?
EFS PVCs don't have any size limits. EFS PVC 没有任何大小限制。 Thats why this traditional method doesn't work while checking their disk usage.
这就是为什么这种传统方法在检查磁盘使用情况时不起作用的原因。 Instead, I was able to use a sidecar-logging mechanism to get this data -
相反,我能够使用 sidecar-logging 机制来获取这些数据 -
Attach the following sidecar to the pod which is using the PVC myPvcName
将以下 sidecar 附加到使用 PVC
myPvcName
的 pod
containers:
- name: pvc-logging
image: busybox:latest
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do du -sh /myPvc ; sleep 5; done;" ]
volumeMounts:
- mountPath: /myPvc
name: myPvc
readOnly: true
volumes:
- name: myPvc
persistentVolumeClaim:
claimName: myPvcName
This sidecar -这辆边车——
MyPvcName
pvc mounted at the path /myPvc
MyPvcName
pvc 安装在路径/myPvc
It's logs look like -它的日志看起来像 -
10.3G /myPvc
10.3G /myPvc
10.4G /myPvc
These can be parsed using whatever logging stack you use - in my case, it was the elastic stack.这些可以使用您使用的任何日志堆栈来解析 - 在我的情况下,它是弹性堆栈。
But I haven't yet looked into how I can send these logs into prometheus so I can visualise them on Grafana.但我还没有研究如何将这些日志发送到 prometheus,以便我可以在 Grafana 上可视化它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.