jmcgrath207 / k8s-ephemeral-storage-metrics

Prometheus ephemeral storage metrics exporter
https://jmcgrath207.github.io/k8s-ephemeral-storage-metrics/
MIT License
85 stars 35 forks source link

ephemeral_storage_pod_usage Can empty directory memory be supported? #85

Closed jicki closed 4 months ago

jicki commented 4 months ago

ephemeral_storage_pod_usage. Can empty directory memory be supported?

  volumes:
  - name: cache-volume
    emptyDir:
      medium: Memory
      sizeLimit: 500Mi
jmcgrath207 commented 4 months ago

I am not testing for the medium memory part, but other than that, we do have a metric for this that should meet your need.

ephemeral_storage_container_volume_limit_percentage

Here is what our test looks like.

https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics/blob/master/chart/templates/test_deployments.yaml#L31-L37

So if you deploy with dev.enabled: true in your values, you can see the grow and shrink pods in action that will reflect this metric.

jicki commented 4 months ago

I am not testing for the medium memory part, but other than that, we do have a metric for this that should meet your need.

ephemeral_storage_container_volume_limit_percentage

Here is what our test looks like.

https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics/blob/master/chart/templates/test_deployments.yaml#L31-L37

So if you deploy with dev.enabled: true in your values, you can see the grow and shrink pods in action that will reflect this metric.

ephemeral_storage_container_volume_limit_percentage This metric only takes effect when using the sizeLimit of an empty directory.

I tested the metric ephemeral_storage_pod_usage, and in the case where the empty directory type is memory, there will be no increment. Also, if a pod has multiple containers, the display can become cluttered. It would be better if mount points could be loaded and containers displayed separately.

jmcgrath207 commented 4 months ago

ephemeral_storage_container_volume_limit_percentage This metric only takes effect when using the sizeLimit of an empty directory.

Correct, this is intended since we need to know the size limit/ceiling to get the percentage.

I tested the metric ephemeral_storage_pod_usage, and in the case where the empty directory type is memory, there will be no increment.

My guess is CaAdvisor is not reflecting it correctly when medium: Memory. Here is the raw command that I source from.

node_name="your-node"
kubectl get --raw "/api/v1/nodes/$node_name/proxy/stats/summary"
...

   "ephemeral-storage": {
    "time": "2024-04-25T03:29:01Z",
    "availableBytes": 326768394240,
    "capacityBytes": 983036076032,
    "usedBytes": 8192,
    "inodesFree": 50534940,
    "inodes": 61030400,
    "inodesUsed": 2
   },

Curious to what you find.

Also, if a pod has multiple containers, the display can become cluttered. It would be better if mount points could be loaded and containers displayed separately.

Could you share of the sample output of what you are wanting? ex.

ephemeral_storage_pod_usage{node_name="minikube",pod_name="etcd-minikube",pod_namespace="kube-system"} 8192

Thanks!

jicki commented 4 months ago

I've submitted a PR; you can take a look. https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics/pull/87

jmcgrath207 commented 4 months ago

@jicki you change is live in 1.9.0