Skip to content

Docker stats output mismatch between Ubuntu 20 and Ubuntu24 #3326

Open
@sumanshil

Description

@sumanshil

We are using docker library to get the docker container stats. We are running a python program periodically to get the stats. The python program is running in a docker container which has base image U24 and python version 3.12. If we run the container in EC2 hosts we are seeing different output based on EC2 OS version. It looks like U24 has missing fields.

client = docker.APIClient(base_url='unix:///var/run/docker.sock')
stats = client.stats(containerid, stream=False)

In Ubuntu 24 host we are getting the following output. Please note that rss is missing from memory_stats/stats section.


   },
   "blkio_stats":{
      "io_service_bytes_recursive":[
         {
            "major":259,
            "minor":1,
            "op":"read",
            "value":0
         },
         {
            "major":259,
            "minor":1,
            "op":"write",
            "value":2276048896
         }
      ],
      "io_serviced_recursive":"None",
      "io_queue_recursive":"None",
      "io_service_time_recursive":"None",
      "io_wait_time_recursive":"None",
      "io_merged_recursive":"None",
      "io_time_recursive":"None",
      "sectors_recursive":"None"
   },
   "num_procs":0,
   "storage_stats":{
      
   },
   "cpu_stats":{
      "cpu_usage":{
         "total_usage":734205459000,
         "usage_in_kernelmode":106087967000,
         "usage_in_usermode":628117492000
      },
      "system_cpu_usage":297437680000000,
      "online_cpus":4,
      "throttling_data":{
         "periods":55775,
         "throttled_periods":483,
         "throttled_time":2097567000
      }
   },
   "precpu_stats":{
      "cpu_usage":{
         "total_usage":734205438000,
         "usage_in_kernelmode":106087963000,
         "usage_in_usermode":628117474000
      },
      "system_cpu_usage":297433700000000,
      "online_cpus":4,
      "throttling_data":{
         "periods":55775,
         "throttled_periods":483,
         "throttled_time":2097567000
      }
   },
   "memory_stats":{
      "usage":598380544,
      "stats":{
         "active_anon":351952896,
         "active_file":0,
         "anon":351952896,
         "anon_thp":0,
         "file":234229760,
         "file_dirty":192512,
         "file_mapped":0,
         "file_writeback":0,
         "inactive_anon":0,
         "inactive_file":234229760,
         "kernel_stack":49152,
         "pgactivate":0,
         "pgdeactivate":0,
         "pgfault":5154048,
         "pglazyfree":0,
         "pglazyfreed":0,
         "pgmajfault":0,
         "pgrefill":0,
         "pgscan":0,
         "pgsteal":0,
         "shmem":0,
         "slab":11209248,
         "slab_reclaimable":10967680,
         "slab_unreclaimable":241568,
         "sock":20480,
         "thp_collapse_alloc":0,
         "thp_fault_alloc":0,
         "unevictable":0,
         "workingset_activate":0,
         "workingset_nodereclaim":0,
         "workingset_refault":0
      },
      "limit":2147483648
   },
   "name":"/zk_update_monitor",
   "id":"bffcbc4be164415395599fb2a64c662cec249726c2560d5558cd8fdd5cb7912c"
}

Ububtu 20 host output

{
   "read":"2025-03-29T19:47:35.324047694Z",
   "preread":"2025-03-29T19:47:34.32246164Z",
   "pids_stats":{
      "current":2
   },
   "blkio_stats":{
      "io_service_bytes_recursive":[
         {
            "major":259,
            "minor":0,
            "op":"Read",
            "value":212992
         },
         {
            "major":259,
            "minor":0,
            "op":"Write",
            "value":0
         },
         {
            "major":259,
            "minor":0,
            "op":"Sync",
            "value":212992
         },
         {
            "major":259,
            "minor":0,
            "op":"Async",
            "value":0
         },
         {
            "major":259,
            "minor":0,
            "op":"Discard",
            "value":0
         },
         {
            "major":259,
            "minor":0,
            "op":"Total",
            "value":212992
         }
      ],
      "io_serviced_recursive":[
         {
            "major":259,
            "minor":0,
            "op":"Read",
            "value":7
         },
         {
            "major":259,
            "minor":0,
            "op":"Write",
            "value":0
         },
         {
            "major":259,
            "minor":0,
            "op":"Sync",
            "value":7
         },
         {
            "major":259,
            "minor":0,
            "op":"Async",
            "value":0
         },
         {
            "major":259,
            "minor":0,
            "op":"Discard",
            "value":0
         },
         {
            "major":259,
            "minor":0,
            "op":"Total",
            "value":7
         }
      ],
      "io_queue_recursive":[
         
      ],
      "io_service_time_recursive":[
         
      ],
      "io_wait_time_recursive":[
         
      ],
      "io_merged_recursive":[
         
      ],
      "io_time_recursive":[
         
      ],
      "sectors_recursive":[
         
      ]
   },
   "num_procs":0,
   "storage_stats":{
      
   },
   "cpu_stats":{
      "cpu_usage":{
         "total_usage":119435166760,
         "percpu_usage":[
            7973124684,
            7616021498,
            7490138159,
            7477351399,
            7543572417,
            7768791189,
            7483028159,
            7648588078,
            7340081608,
            7015214610,
            7439784698,
            7335021747,
            7613283937,
            7365167100,
            6832955680,
            7493041797
         ],
         "usage_in_kernelmode":39320000000,
         "usage_in_usermode":63950000000
      },
      "system_cpu_usage":129103361792904483,
      "online_cpus":16,
      "throttling_data":{
         "periods":19263,
         "throttled_periods":0,
         "throttled_time":0
      }
   },
   "precpu_stats":{
      "cpu_usage":{
         "total_usage":119435146170,
         "percpu_usage":[
            7973124684,
            7616021498,
            7490138159,
            7477351399,
            7543572417,
            7768791189,
            7483028159,
            7648588078,
            7340081608,
            7015214610,
            7439784698,
            7335021747,
            7613283937,
            7365146510,
            6832955680,
            7493041797
         ],
         "usage_in_kernelmode":39320000000,
         "usage_in_usermode":63950000000
      },
      "system_cpu_usage":129103345812904483,
      "online_cpus":16,
      "throttling_data":{
         "periods":19263,
         "throttled_periods":0,
         "throttled_time":0
      }
   },
   "memory_stats":{
      "usage":12464128,
      "max_usage":16515072,
      "stats":{
         "active_anon":946176,
         "active_file":0,
         "cache":135168,
         "dirty":0,
         "hierarchical_memory_limit":2147483648,
         "hierarchical_memsw_limit":0,
         "inactive_anon":0,
         "inactive_file":135168,
         "mapped_file":0,
         "pgfault":10959828,
         "pgmajfault":0,
         "pgpgin":6423846,
         "pgpgout":6423718,
         "rss":724992,
         "rss_huge":0,
         "total_active_anon":946176,
         "total_active_file":0,
         "total_cache":135168,
         "total_dirty":0,
         "total_inactive_anon":0,
         "total_inactive_file":135168,
         "total_mapped_file":0,
         "total_pgfault":10959828,
         "total_pgmajfault":0,
         "total_pgpgin":6423846,
         "total_pgpgout":6423718,
         "total_rss":724992,
         "total_rss_huge":0,
         "total_unevictable":0,
         "total_writeback":0,
         "unevictable":0,
         "writeback":0
      },
      "limit":2147483648
   },
   "name":"/envoy-B",
   "id":"3bd2c6856dbbbe7cad76cf7b141fc7ae26d22e8bb6eea1ef10600c7b859e75ec"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions