docker / docker/docker-py

Statistics not displaying properly

Open
#3,129 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/need-info
Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

Hello there, everyone,

I'm trying to use the docker python SDK in order to fetch data from the statistics of certain containers I have previously deployed. The thing is, every time I try to fetch said statistics, I always get the same values. The code I have been working is the following:

import docker    
client =docker.from_env()    
stat_stream = client.containers.get(container_id="8201d665ecd1d50240266b85bf8a6853503cda5442c3b9de437cc99ff23fee3a").stats(stream=True)
for line in stat_stream:
   print(line.strip().decode(),"\n")

And for the previously shown code, I get the following dictionary printed constantly:

{
"read":"0001-01-01T00:00:00Z",
"preread":"0001-01-01T00:00:00Z",
"pids_stats":{},
"blkio_stats":{
   "io_service_bytes_recursive":null,
   "io_serviced_recursive":null,
   "io_queue_recursive":null,
   "io_service_time_recursive":null,
   "io_wait_time_recursive":null,
   "io_merged_recursive":null,
   "io_time_recursive":null,
   "sectors_recursive":null
},
"num_procs":0,
"storage_stats":{},
"cpu_stats":{
   "cpu_usage":{
      "total_usage":0,
      "usage_in_kernelmode":0,
      "usage_in_usermode":0
   },
   "throttling_data":{
      "periods":0,
      "throttled_periods":0,
      "throttled_time":0
   }
},
"precpu_stats":{
   "cpu_usage":{
      "total_usage":0,
      "usage_in_kernelmode":0,
      "usage_in_usermode":0
   },
   "throttling_data":{
      "periods":0,
      "throttled_periods":0,
      "throttled_time":0
   }
},
"memory_stats":{},
"name":"/lab-sniffer-1",
"id":"8201d665ecd1d50240266b85bf8a6853503cda5442c3b9de437cc99ff23fee3a"
}

NOTE: I've added some line breaks in order to make it more easily readable

I was wondering if anybody knew where the problem may be, there must be something I'm doing wrong but can't figure out what it is.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with client.containers.get(...).stats(stream=True) and inspect the repeated statistics dictionary. Check whether the behavior is specific to the Python SDK or the Docker Engine API, then identify the relevant entry point and an expected result before determining what would count as fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.