containers / prometheus-podman-exporter

Prometheus exporter for podman environments exposing containers, pods, images, volumes and networks information.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: allow cached scraping of container size

ykuksenko opened this issue · comments

Is your feature request related to a problem? Please describe.
When creating containers one can miss mounting volumes to important locations.

  • This way important data can be written to container layer instead of a volume or a mount. If the container is deleted (or stopped with the --rm flag) the data is gone with it.
  • The container could also have logs or other data that grows without bound that is not part of volume and may be difficult to resize.

Ideally containers would be of size 0 with all data in volumes but this is rarely the case. This would be a good sanity check.

Describe the solution you'd like
I would like to see tunable cached container size metrics added. Specifically the size attributes from podman ps --size --format=json.

  • This is an expensive metric to collect because containers are usually mutable and their size unpredictable so it would need to be cached.
    • Cache duration should be tunable as this will affect different systems differently.
    • The default cache duration should be once every 24 hours.
    • Once the cache expires serve the old data and start fetching new data?
    • Ideally size collection for each container would distributed over the course of the tunable period to avoid sending too much IO to the system at the same time.

Additional context

  • It is likely not important for this metric to be collected frequently. I think it will be most helpful with long lived containers.
  • Image and volume sizes do not cover this aspect.

Thank you for considering this.

A friendly reminder that this issue had no activity for 30 days.

A friendly reminder that this issue had no activity for 30 days.

A friendly reminder that this issue had no activity for 30 days.

Hi @ykuksenko

#203 added container size metrics (root filesystem size and top read-write layer size):

  • podman_container_rootfs_size_bytes
  • podman_container_rw_size_bytes

the container size will be cached and it will be refresh every 3600 seconds (1hour), the duration is tunable via collector.cache_duration command line option.