@@ -37,12 +37,12 @@ async def lifespan(app: FastAPI):
3737gauge_memory_percentage = Gauge ('cxp_memory_percentage' , 'Docker container memory usage in percent' , ['container_name' ])
3838gauge_memory_bytes = Gauge ('cxp_memory_bytes_total' , 'Docker container memory usage in bytes' , ['container_name' ])
3939
40- counter_disk_read = Gauge ("cxp_disk_io_read_bytes_total" , "Total bytes read from disk" , ['container_name' ])
41- counter_disk_write = Gauge ("cxp_disk_io_write_bytes_total" , "Total bytes written to disk" , ['container_name' ])
42- counter_net_rx = Gauge ("cxp_network_rx_bytes_total" , "Total bytes received over network" , ['container_name' ])
43- counter_net_tx = Gauge ("cxp_network_tx_bytes_total" , "Total bytes sent over network" , ['container_name' ])
40+ gauge_disk_read = Gauge ("cxp_disk_io_read_bytes_total" , "Total bytes read from disk" , ['container_name' ])
41+ gauge_disk_write = Gauge ("cxp_disk_io_write_bytes_total" , "Total bytes written to disk" , ['container_name' ])
42+ gauge_net_rx = Gauge ("cxp_network_rx_bytes_total" , "Total bytes received over network" , ['container_name' ])
43+ gauge_net_tx = Gauge ("cxp_network_tx_bytes_total" , "Total bytes sent over network" , ['container_name' ])
4444
45- counter_running_containers_total = Gauge ("cxp_running_cotainers_total" , "Total number of running containers" )
45+ gauge_running_containers_total = Gauge ("cxp_running_cotainers_total" , "Total number of running containers" )
4646
4747async def get_containers (all = False ) -> list [DockerContainer ]:
4848 return await docker_client .containers .list (all = all )
@@ -62,7 +62,7 @@ async def container_stats(running_containers: list[DockerContainer]):
6262 all_stats = await stat .get_containers_stats (running_containers )
6363 running_containers_total = len (running_containers )
6464
65- counter_running_containers_total .set (running_containers_total )
65+ gauge_running_containers_total .set (running_containers_total )
6666
6767 for stats in all_stats :
6868 name = stats [0 ].get ('name' , stats [0 ].get ('id' , 'Unkown' ).lstrip ("/" )).lstrip ("/" )
@@ -73,20 +73,20 @@ async def container_stats(running_containers: list[DockerContainer]):
7373 disk_read , disk_write = stat .calculate_disk_io (stats [0 ])
7474 net_rx , net_tx = stat .calculate_network_io (stats [0 ])
7575
76- counter_disk_read .labels (container_name = name ).set (disk_read )
77- counter_disk_write .labels (container_name = name ).set (disk_write )
78- counter_net_rx .labels (container_name = name ).set (net_rx )
79- counter_net_tx .labels (container_name = name ).set (net_tx )
76+ gauge_disk_read .labels (container_name = name ).set (disk_read )
77+ gauge_disk_write .labels (container_name = name ).set (disk_write )
78+ gauge_net_rx .labels (container_name = name ).set (net_rx )
79+ gauge_net_tx .labels (container_name = name ).set (net_tx )
8080
8181# List of metrics we want to prune (performance counters)
8282prunable_metrics : list [PromMetric ] = [
8383 gauge_cpu_percentage , gauge_memory_percentage , gauge_memory_bytes ,
84- counter_disk_read , counter_disk_write , counter_net_rx , counter_net_tx
84+ gauge_disk_read , gauge_disk_write , gauge_net_rx , gauge_net_tx
8585]
8686
8787# Metrics we want to always keep, and set to 0 instead
8888persistent_metrics : list [Gauge ] = [
89- gauge_container_status , counter_running_containers_total
89+ gauge_container_status , gauge_running_containers_total
9090]
9191
9292
0 commit comments