Skip to content

Commit

Permalink
Fix bug when normalizing CPU shares
Browse files Browse the repository at this point in the history
  • Loading branch information
raags committed Jun 22, 2021
1 parent a78f64b commit f123f4c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ecs_container_exporter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f123f4c

Please sign in to comment.