diff --git a/ecs_container_exporter/main.py b/ecs_container_exporter/main.py index 8fa3fc9..bbc565c 100755 --- a/ecs_container_exporter/main.py +++ b/ecs_container_exporter/main.py @@ -178,12 +178,17 @@ def should_process_container(self, container_name, include_containers, exclude_c return True def cpu_mem_limit(self, metadata): - # normalise to `cpu shares` - cpu_limit = metadata.get('Limits', {}).get('CPU', 0) * 1024 + cpu_limit = metadata.get('Limits', {}).get('CPU', 0) + + # Can be CPU shares or CPU units + # normalize to `CPU shares` since 256 is min share + scale_factor = 1024 if cpu_limit < 256 else 1 + mem_limit = metadata.get('Limits', {}).get('Memory', 0) return ( - cpu_limit, mem_limit + cpu_limit * scale_factor, + mem_limit ) # All metrics are collected here