Open
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.